Class: DataTypes::Float64
- 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 = {}) ⇒ Float64
constructor
A new instance of Float64.
- #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 = {}) ⇒ Float64
Returns a new instance of Float64.
240 241 242 |
# File 'lib/active_model_serializers_binary/data_types.rb', line 240 def initialize( = {}) super .merge :bit_length => 64, :sign => nil, :default_value => 0.0 end |
Instance Method Details
#dump(value = nil) ⇒ Object
244 245 246 247 248 249 250 251 |
# File 'lib/active_model_serializers_binary/data_types.rb', line 244 def dump(value=nil) before_dump( value ) if @endianess == :big @raw_value = @value.pack('G*').unpack('C*') else @raw_value = @value.pack('E*').unpack('C*') end end |
#load(raw_value) ⇒ Object
253 254 255 256 257 258 259 260 |
# File 'lib/active_model_serializers_binary/data_types.rb', line 253 def load(raw_value) if @endianess == :big self.value = check_raw_value(raw_value).pack('C*').unpack('G*') if !value.nil? else self.value = check_raw_value(raw_value).pack('C*').unpack('E*') if !value.nil? end after_load end |