Class: Avro::Schema::FixedSchema

Inherits:
NamedSchema show all
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

Attributes inherited from NamedSchema

#name, #namespace

Attributes inherited from Avro::Schema

#logical_type, #type_sym

Instance Method Summary collapse

Methods inherited from NamedSchema

#fullname

Methods inherited from Avro::Schema

#==, #be_read?, #hash, #md5_fingerprint, #mutual_read?, parse, #read?, real_parse, #sha256_fingerprint, #subparse, #to_s, #type, #type_adapter, validate

Constructor Details

#initialize(name, space, size, names = nil, logical_type = nil) ⇒ FixedSchema

Returns a new instance of FixedSchema.



344
345
346
347
348
349
350
351
# File 'lib/avro/schema.rb', line 344

def initialize(name, space, size, names=nil, logical_type=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, logical_type)
  @size = size
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



343
344
345
# File 'lib/avro/schema.rb', line 343

def size
  @size
end

Instance Method Details

#to_avro(names = Set.new) ⇒ Object



353
354
355
356
# File 'lib/avro/schema.rb', line 353

def to_avro(names=Set.new)
  avro = super
  avro.is_a?(Hash) ? avro.merge('size' => size) : avro
end