Class: SavonHelper::IntegerMapping

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

Overview

IntegerMapping maps Savon data to Ruby integers.

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:



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

def default_value
  0
end

#object_klassInteger

Return the class represented by the mapping.

Returns:

  • (Integer)


121
122
123
# File 'lib/savon_helper/type_mappings.rb', line 121

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)


106
107
108
# File 'lib/savon_helper/type_mappings.rb', line 106

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:



113
114
115
# File 'lib/savon_helper/type_mappings.rb', line 113

def to_savon(value)
  value.to_s
end

#type_stringString

Return the class description represented by the mapping.

Returns:



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

def type_string
  "int"
end