Class: Jerakia::Answer
- Inherits:
-
Object
- Object
- Jerakia::Answer
- Defined in:
- lib/jerakia/answer.rb
Instance Attribute Summary collapse
-
#datatype ⇒ Object
Returns the value of attribute datatype.
-
#lookup_type ⇒ Object
readonly
Returns the value of attribute lookup_type.
-
#payload ⇒ Object
Returns the value of attribute payload.
Instance Method Summary collapse
- #flatten_payload! ⇒ Object
-
#initialize(lookup_type = :first) ⇒ Answer
constructor
A new instance of Answer.
- #merge_payload! ⇒ Object
- #set_data_type ⇒ Object
Constructor Details
#initialize(lookup_type = :first) ⇒ Answer
Returns a new instance of Answer.
7 8 9 10 11 12 13 14 15 |
# File 'lib/jerakia/answer.rb', line 7 def initialize(lookup_type = :first) case lookup_type when :first @payload=nil when :cascade @payload=[] @datatype="array" end end |
Instance Attribute Details
#datatype ⇒ Object
Returns the value of attribute datatype.
4 5 6 |
# File 'lib/jerakia/answer.rb', line 4 def datatype @datatype end |
#lookup_type ⇒ Object (readonly)
Returns the value of attribute lookup_type.
5 6 7 |
# File 'lib/jerakia/answer.rb', line 5 def lookup_type @lookup_type end |
#payload ⇒ Object
Returns the value of attribute payload.
3 4 5 |
# File 'lib/jerakia/answer.rb', line 3 def payload @payload end |
Instance Method Details
#flatten_payload! ⇒ Object
17 18 19 |
# File 'lib/jerakia/answer.rb', line 17 def flatten_payload! @payload.flatten! end |
#merge_payload! ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jerakia/answer.rb', line 21 def merge_payload! payload_hash={} @payload.each do |p| if p.is_a?(Hash) payload_hash.merge!(p) end end @payload=payload_hash set_data_type end |
#set_data_type ⇒ Object
32 33 34 |
# File 'lib/jerakia/answer.rb', line 32 def set_data_type @data_type=@payload.class.to_s.downcase end |