Class: PlayAsia::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/play_asia/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contentObject (readonly)

Returns the value of attribute content.



7
8
9
# File 'lib/play_asia/response.rb', line 7

def content
  @content
end

#itemsObject (readonly)

Returns the value of attribute items.



7
8
9
# File 'lib/play_asia/response.rb', line 7

def items
  @items
end

#raw_textObject (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

#statusObject (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

Returns:

  • (Boolean)


41
42
43
# File 'lib/play_asia/response.rb', line 41

def complete?
  !has_more?
end

#error?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/play_asia/response.rb', line 16

def error?
  status[:error] != '0'
end

#error_messageObject



20
21
22
# File 'lib/play_asia/response.rb', line 20

def error_message
  status[:errorstring]
end

#has_more?Boolean

Returns:

  • (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_countObject



32
33
34
# File 'lib/play_asia/response.rb', line 32

def items_count
  status[:items] ? status[:items].to_i : nil
end

#startObject



24
25
26
# File 'lib/play_asia/response.rb', line 24

def start
  status[:start] ? status[:start].to_i : 0
end

#total_itemsObject



28
29
30
# File 'lib/play_asia/response.rb', line 28

def total_items
  status[:total_items] ? status[:total_items].to_i : nil
end