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).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value, opts = {}) ⇒ ResponseValue

Returns a new instance of ResponseValue.



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

def initialize(key, value, opts = {})
  @key = key.to_s
  @value = value
  @opts = opts
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/soapy_cake/response_value.rb', line 3

def value
  @value
end

Instance Method Details

#parseObject



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

def parse
  return parse_int if id? && !string_id?
  return false if false?
  return true if true?
  return parse_date if date?

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