Class: Response
- Inherits:
-
Object
- Object
- Response
- Defined in:
- lib/rawapi/response.rb
Overview
The Response object is the ruby object version of the webservice response.
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#feeds ⇒ Object
Returns the value of attribute feeds.
-
#message ⇒ Object
Returns the value of attribute message.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize ⇒ Response
constructor
A new instance of Response.
-
#to_s ⇒ Object
returns a formated string representing the response object.
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
5 6 7 |
# File 'lib/rawapi/response.rb', line 5 def initialize @feeds = [] end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
3 4 5 |
# File 'lib/rawapi/response.rb', line 3 def code @code end |
#feeds ⇒ Object
Returns the value of attribute feeds.
3 4 5 |
# File 'lib/rawapi/response.rb', line 3 def feeds @feeds end |
#message ⇒ Object
Returns the value of attribute message.
3 4 5 |
# File 'lib/rawapi/response.rb', line 3 def @message end |
#status ⇒ Object
Returns the value of attribute status.
3 4 5 |
# File 'lib/rawapi/response.rb', line 3 def status @status end |
Instance Method Details
#to_s ⇒ Object
returns a formated string representing the response object. good for debugging.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rawapi/response.rb', line 10 def to_s output = [] output << "Status: #{@status}" output << "Code: #{@code}" if @code output << "Message: #{@message}" if @message for feed in @feeds output << "-Feed" output << " Id: #{feed.id}" if feed.id output << " URI: #{feed.uri}" if feed.uri for entry in feed.entries output << " -Entry" output << " Date: #{entry.date}" if entry.date output << " Circulation: #{entry.circulation}" if entry.circulation output << " Hits: #{entry.hits}" if entry.hits for item in entry.items output << " -Item" output << " Title: #{item.title}" if item.title output << " URL: #{item.url}" if item.url output << " ItemViews: #{item.itemviews}" if item.itemviews output << " Clickthoughs: #{item.clickthroughs}" if item.clickthroughs for referer in item.referers output << " -Referer" output << " URL: #{referer.url}" if referer.url output << " ItemViews: #{referer.itemviews}" if referer.itemviews output << " Clickthoughs: #{referer.clickthroughs}" if referer.clickthroughs end end end end return output.join("\n") end |