Class: DataTypes::UInt32
- Defined in:
- lib/active_model_serializers_binary/data_types.rb
Instance Attribute Summary
Attributes inherited from BaseType
#bit_length, #count, #endianess, #length, #name, #parent, #raw_value, #sign, #type, #value
Instance Method Summary collapse
- #dump(value = nil) ⇒ Object
-
#initialize(options = {}) ⇒ UInt32
constructor
A new instance of UInt32.
- #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 = {}) ⇒ UInt32
95 96 97 |
# File 'lib/active_model_serializers_binary/data_types.rb', line 95 def initialize( = {}) super .merge :bit_length => 32, :sign => :unsigned end |
Instance Method Details
#dump(value = nil) ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/active_model_serializers_binary/data_types.rb', line 99 def dump(value=nil) before_dump( value ) if @endianess == :big @raw_value = @value.pack('L>*').unpack('C*') else @raw_value = @value.pack('L<*').unpack('C*') end end |
#load(raw_value) ⇒ Object
108 109 110 111 112 113 114 115 |
# File 'lib/active_model_serializers_binary/data_types.rb', line 108 def load(raw_value) if @endianess == :big self.value = check_raw_value(raw_value).pack('C*').unpack('L>*') if !value.nil? else self.value = check_raw_value(raw_value).pack('C*').unpack('L<*') if !value.nil? end after_load end |