Class: SoapyCake::ResponseValue

Inherits:
Object
  • Object
show all
Defined in:
lib/soapy_cake/response_value.rb

Constant Summary collapse

STRING_IDS =

Known string ids that should not be parsed as integers

%w[tax_id transaction_id sub_id].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value, time_converter) ⇒ ResponseValue

Returns a new instance of ResponseValue.



10
11
12
13
14
# File 'lib/soapy_cake/response_value.rb', line 10

def initialize(key, value, time_converter)
  @key = key.to_s
  @value = value
  @time_converter = time_converter
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/soapy_cake/response_value.rb', line 5

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



5
6
7
# File 'lib/soapy_cake/response_value.rb', line 5

def value
  @value
end

Instance Method Details

#parseObject



16
17
18
19
20
21
22
23
24
# File 'lib/soapy_cake/response_value.rb', line 16

def parse
  return parse_int if id? && !string_id?
  return false if false?
  return true if true?
  return time_converter.from_cake(value) if date?

  # cast to primitive string to get rid of Saxerator string class
  value.to_s
end