Class: DataTypes::Float32
- 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 = {}) ⇒ Float32
constructor
A new instance of Float32.
- #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 = {}) ⇒ Float32
Returns a new instance of Float32.
173 174 175 |
# File 'lib/active_model_serializers_binary/data_types.rb', line 173 def initialize( = {}) super .merge :bit_length => 32, :sign => nil, :default_value => 0.0 end |
Instance Method Details
#dump(value = nil) ⇒ Object
177 178 179 180 |
# File 'lib/active_model_serializers_binary/data_types.rb', line 177 def dump(value=nil) before_dump( value ) @raw_value = @value.pack('e*').unpack('C*') end |
#load(raw_value) ⇒ Object
182 183 184 185 |
# File 'lib/active_model_serializers_binary/data_types.rb', line 182 def load(raw_value) self.value = check_raw_value(raw_value).pack('C*').unpack('e*') if !value.nil? after_load end |