Module: Icss::Meta::FixedType

Defined in:
lib/icss/type/structured_schema.rb

Overview

A Fixed-length buffer. The class size specifies the number of bytes per value (required).

Defined Under Namespace

Classes: FixedValueWrongSizeError

Instance Method Summary collapse

Instance Method Details

#receive(raw) ⇒ Object

accept like a string but enforce (violently) the length constraint



118
119
120
121
122
# File 'lib/icss/type/structured_schema.rb', line 118

def receive(raw)
  obj = super(raw) ; return nil if obj.blank?
  unless obj.bytesize == self.size then raise FixedValueWrongSizeError.new("Wrong size for a fixed-length type #{self.fullname}: got #{obj.bytesize}, not #{self.size}") ; end
  obj
end

#to_schemaObject



123
# File 'lib/icss/type/structured_schema.rb', line 123

def to_schema() _schema.to_hash end