Class: WhatCounts::Response
- Inherits:
-
Object
- Object
- WhatCounts::Response
- Defined in:
- lib/whatcounts/response.rb
Constant Summary collapse
- SUCCESS =
true
- FAILURE =
false
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(url, document) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(url, document) ⇒ Response
Returns a new instance of Response.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/whatcounts/response.rb', line 12 def initialize(url,document) self.url = url if document =~ /^(SUCCESS|FAILURE):?(.*)/ # simple response self.body = $2.strip case $1 when "SUCCESS" self.result = SUCCESS when "FAILURE" self.result = FAILURE end else # TODO data based response self.body = document end end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
7 8 9 |
# File 'lib/whatcounts/response.rb', line 7 def body @body end |
#result ⇒ Object
Returns the value of attribute result.
7 8 9 |
# File 'lib/whatcounts/response.rb', line 7 def result @result end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/whatcounts/response.rb', line 7 def url @url end |
Instance Method Details
#failure? ⇒ Boolean
30 |
# File 'lib/whatcounts/response.rb', line 30 def failure?; !self.result end |
#success? ⇒ Boolean
29 |
# File 'lib/whatcounts/response.rb', line 29 def success?; !!self.result end |