Class: DataTypes::UInt16
- Defined in:
- lib/active_model_serializers_binary/data_types.rb
Instance Attribute Summary
Attributes inherited from Type
#bit_length, #count, #length, #name, #parent, #raw_value, #sign, #type, #value
Instance Method Summary collapse
- #dump(value = nil) ⇒ Object
-
#initialize(options = {}) ⇒ UInt16
constructor
A new instance of UInt16.
- #load(raw_value) ⇒ Object
Methods inherited from Type
#after_load, #before_dump, #check, #check_raw_value, #check_value, #size, #to_s, #trim
Constructor Details
#initialize(options = {}) ⇒ UInt16
Returns a new instance of UInt16.
54 55 56 |
# File 'lib/active_model_serializers_binary/data_types.rb', line 54 def initialize( = {}) super .merge :bit_length => 16, :sign => :unsigned end |
Instance Method Details
#dump(value = nil) ⇒ Object
58 59 60 61 |
# File 'lib/active_model_serializers_binary/data_types.rb', line 58 def dump(value=nil) before_dump( value ) @raw_value = @value.pack('v*').unpack('C*') end |
#load(raw_value) ⇒ Object
63 64 65 66 67 |
# File 'lib/active_model_serializers_binary/data_types.rb', line 63 def load(raw_value) @raw_value = check_raw_value(raw_value) self.value = @raw_value.pack('C*').unpack('v*') after_load end |