Class: Avro::Schema::FixedSchema
- Inherits:
-
NamedSchema
- Object
- Schema
- NamedSchema
- Avro::Schema::FixedSchema
- Defined in:
- lib/avro/schema.rb
Instance Attribute Summary collapse
-
#precision ⇒ Object
readonly
Returns the value of attribute precision.
-
#scale ⇒ Object
readonly
Returns the value of attribute scale.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Attributes inherited from NamedSchema
Instance Method Summary collapse
-
#initialize(name, space, size, names = nil, logical_type = nil, aliases = nil, precision = nil, scale = nil) ⇒ FixedSchema
constructor
A new instance of FixedSchema.
- #match_schema?(schema) ⇒ Boolean
- #to_avro(names = Set.new) ⇒ Object
Methods inherited from NamedSchema
#fullname, #fullname_aliases, #match_fullname?
Constructor Details
#initialize(name, space, size, names = nil, logical_type = nil, aliases = nil, precision = nil, scale = nil) ⇒ FixedSchema
Returns a new instance of FixedSchema.
533 534 535 536 537 538 539 540 541 542 |
# File 'lib/avro/schema.rb', line 533 def initialize(name, space, size, names=nil, logical_type=nil, aliases=nil, precision=nil, scale=nil) # Ensure valid cto args unless size.is_a?(Integer) raise AvroError, 'Fixed Schema requires a valid integer for size property.' end super(:fixed, name, space, names, nil, logical_type, aliases) @size = size @precision = precision @scale = scale end |
Instance Attribute Details
#precision ⇒ Object (readonly)
Returns the value of attribute precision.
532 533 534 |
# File 'lib/avro/schema.rb', line 532 def precision @precision end |
#scale ⇒ Object (readonly)
Returns the value of attribute scale.
532 533 534 |
# File 'lib/avro/schema.rb', line 532 def scale @scale end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
532 533 534 |
# File 'lib/avro/schema.rb', line 532 def size @size end |
Instance Method Details
#match_schema?(schema) ⇒ Boolean
554 555 556 557 558 559 560 561 562 |
# File 'lib/avro/schema.rb', line 554 def match_schema?(schema) return true if super && size == schema.size if logical_type == DECIMAL_LOGICAL_TYPE && schema.logical_type == DECIMAL_LOGICAL_TYPE return precision == schema.precision && (scale || 0) == (schema.scale || 0) end false end |
#to_avro(names = Set.new) ⇒ Object
544 545 546 547 548 549 550 551 552 |
# File 'lib/avro/schema.rb', line 544 def to_avro(names=Set.new) avro = super return avro if avro.is_a?(String) avro['size'] = size avro['precision'] = precision if precision avro['scale'] = scale if scale avro end |