Class: PlayAsia::Response
- Inherits:
-
Object
- Object
- PlayAsia::Response
- Defined in:
- lib/play_asia/response.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#raw_text ⇒ Object
readonly
Returns the value of attribute raw_text.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #complete? ⇒ Boolean
- #error? ⇒ Boolean
- #error_message ⇒ Object
- #has_more? ⇒ Boolean
-
#initialize(text) ⇒ Response
constructor
A new instance of Response.
- #items_count ⇒ Object
- #start ⇒ Object
- #total_items ⇒ Object
Constructor Details
#initialize(text) ⇒ Response
Returns a new instance of Response.
9 10 11 12 13 14 |
# File 'lib/play_asia/response.rb', line 9 def initialize(text) @raw_text = text @parsed = Nokogiri::XML.parse text parse_content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'lib/play_asia/response.rb', line 7 def content @content end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
7 8 9 |
# File 'lib/play_asia/response.rb', line 7 def items @items end |
#raw_text ⇒ Object (readonly)
Returns the value of attribute raw_text.
7 8 9 |
# File 'lib/play_asia/response.rb', line 7 def raw_text @raw_text end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/play_asia/response.rb', line 7 def status @status end |
Instance Method Details
#complete? ⇒ Boolean
41 42 43 |
# File 'lib/play_asia/response.rb', line 41 def complete? !has_more? end |
#error? ⇒ Boolean
16 17 18 |
# File 'lib/play_asia/response.rb', line 16 def error? status[:error] != '0' end |
#error_message ⇒ Object
20 21 22 |
# File 'lib/play_asia/response.rb', line 20 def status[:errorstring] end |
#has_more? ⇒ Boolean
36 37 38 39 |
# File 'lib/play_asia/response.rb', line 36 def has_more? raise "Unknown total number of items" if total_items.nil? start + items.size < total_items end |
#items_count ⇒ Object
32 33 34 |
# File 'lib/play_asia/response.rb', line 32 def items_count status[:items] ? status[:items].to_i : nil end |
#start ⇒ Object
24 25 26 |
# File 'lib/play_asia/response.rb', line 24 def start status[:start] ? status[:start].to_i : 0 end |
#total_items ⇒ Object
28 29 30 |
# File 'lib/play_asia/response.rb', line 28 def total_items status[:total_items] ? status[:total_items].to_i : nil end |