Class: SavonHelper::IntegerMapping

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

Overview

IntegerMapping maps Savon data to Ruby integers.

Converting collapse

Instance Method Summary collapse

Methods inherited from TypeMapping

#description, #initialize, #warn_unparseable_data

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:



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

def default_value
  0
end

#object_klassInteger

Return the class represented by the mapping.

Returns:

  • (Integer)


134
135
136
# File 'lib/savon_helper/type_mappings.rb', line 134

def object_klass
  Integer
end

#to_native(data, interface) ⇒ Integer

Convert from Savon data to Ruby integers

Parameters:

  • data (Hash, String)

    Source Savon data

Returns:

  • (Integer)


119
120
121
# File 'lib/savon_helper/type_mappings.rb', line 119

def to_native(data, interface)
  Integer(data.to_s)
end

#to_savon(value) ⇒ String

Convert from Ruby float type to Savon data

Parameters:

  • value (Integer)

    Source Ruby data

Returns:



126
127
128
# File 'lib/savon_helper/type_mappings.rb', line 126

def to_savon(value)
  value.to_s
end

#type_stringString

Return the class description represented by the mapping.

Returns:



140
141
142
# File 'lib/savon_helper/type_mappings.rb', line 140

def type_string
  "int"
end