Class: SavonHelper::FloatMapping

Inherits:
TypeMapping show all
Defined in:
lib/savon_helper/type_mappings.rb

Overview

FloatMapping maps Savon data to Ruby floats.

Instance Attribute Summary

Attributes inherited from TypeMapping

#description, #name

Converting collapse

Instance Method Summary collapse

Methods inherited from TypeMapping

#initialize

Constructor Details

This class inherits a constructor from SavonHelper::TypeMapping

Instance Method Details

#default_valueObject

This method is abstract.

Return the default value the mapping.

Returns:



174
175
176
# File 'lib/savon_helper/type_mappings.rb', line 174

def default_value
  0.0
end

#object_klassFloat

Return the class represented by the mapping.

Returns:

  • (Float)


162
163
164
# File 'lib/savon_helper/type_mappings.rb', line 162

def object_klass
  Float
end

#to_native(data) ⇒ Float

Convert from Savon data to Ruby floats

Parameters:

  • data (Hash, String)

    Source Savon data

Returns:

  • (Float)


147
148
149
# File 'lib/savon_helper/type_mappings.rb', line 147

def to_native(data)
  data.to_f
end

#to_savon(value) ⇒ String

Convert from Ruby float type to Savon data

Parameters:

  • value (Float)

    Source Ruby data

Returns:



154
155
156
# File 'lib/savon_helper/type_mappings.rb', line 154

def to_savon(value)
  value.to_s
end

#type_stringString

Return the class description represented by the mapping.

Returns:



168
169
170
# File 'lib/savon_helper/type_mappings.rb', line 168

def type_string
  "float"
end