Class: DataTypes::Int16
- Defined in:
- lib/active_model_serializers_binary/data_types.rb
Instance Attribute Summary
Attributes inherited from BaseType
#bit_length, #count, #length, #name, #parent, #raw_value, #sign, #type, #value
Instance Method Summary collapse
- #dump(value = nil) ⇒ Object
-
#initialize(options = {}) ⇒ Int16
constructor
A new instance of Int16.
- #load(raw_value) ⇒ Object
Methods inherited from BaseType
#after_load, #before_dump, #check, #check_raw_value, #check_value, #size, #to_s, #trim
Constructor Details
#initialize(options = {}) ⇒ Int16
Returns a new instance of Int16.
22 23 24 |
# File 'lib/active_model_serializers_binary/data_types.rb', line 22 def initialize( = {}) super .merge :bit_length => 16, :sign => :signed end |
Instance Method Details
#dump(value = nil) ⇒ Object
26 27 28 29 |
# File 'lib/active_model_serializers_binary/data_types.rb', line 26 def dump(value=nil) before_dump( value ) @raw_value = @value.pack('s<*').unpack('C*') end |
#load(raw_value) ⇒ Object
31 32 33 34 |
# File 'lib/active_model_serializers_binary/data_types.rb', line 31 def load(raw_value) self.value = check_raw_value(raw_value).pack('C*').unpack('s<*') after_load end |