Class: Avro::Schema::EnumSchema
- Inherits:
-
NamedSchema
- Object
- Avro::Schema
- NamedSchema
- Avro::Schema::EnumSchema
- Defined in:
- lib/avro/schema.rb
Constant Summary
Constants inherited from Avro::Schema
INT_MAX_VALUE, INT_MIN_VALUE, LONG_MAX_VALUE, LONG_MIN_VALUE, NAMED_TYPES, NAMED_TYPES_SYM, PRIMITIVE_TYPES, PRIMITIVE_TYPES_SYM, VALID_TYPES, VALID_TYPES_SYM
Instance Attribute Summary collapse
-
#symbols ⇒ Object
readonly
Returns the value of attribute symbols.
Attributes inherited from NamedSchema
Attributes inherited from Avro::Schema
Instance Method Summary collapse
-
#initialize(name, space, symbols, names = nil) ⇒ EnumSchema
constructor
A new instance of EnumSchema.
- #to_avro(names = Set.new) ⇒ Object
Methods inherited from NamedSchema
Methods inherited from Avro::Schema
#==, #hash, parse, real_parse, #subparse, #to_s, #type, validate
Constructor Details
#initialize(name, space, symbols, names = nil) ⇒ EnumSchema
Returns a new instance of EnumSchema.
302 303 304 305 306 307 308 309 |
# File 'lib/avro/schema.rb', line 302 def initialize(name, space, symbols, names=nil) if symbols.uniq.length < symbols.length fail_msg = 'Duplicate symbol: %s' % symbols raise Avro::SchemaParseError, fail_msg end super(:enum, name, space, names) @symbols = symbols end |
Instance Attribute Details
#symbols ⇒ Object (readonly)
Returns the value of attribute symbols.
301 302 303 |
# File 'lib/avro/schema.rb', line 301 def symbols @symbols end |
Instance Method Details
#to_avro(names = Set.new) ⇒ Object
311 312 313 314 |
# File 'lib/avro/schema.rb', line 311 def to_avro(names=Set.new) avro = super avro.is_a?(Hash) ? avro.merge('symbols' => symbols) : avro end |