Class: Radiant::Helper::Response
- Inherits:
-
Object
- Object
- Radiant::Helper::Response
- Defined in:
- lib/radiant_helper_response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#status ⇒ Object
Returns the value of attribute status.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #exception ⇒ Object
- #has_layout? ⇒ Boolean
-
#initialize(url, status, body = "") ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
- #to_s ⇒ Object
- #to_str ⇒ Object
Constructor Details
#initialize(url, status, body = "") ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 |
# File 'lib/radiant_helper_response.rb', line 10 def initialize(url, status, body = "") self.url = url self.status = status.to_i self.body = body end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
7 8 9 |
# File 'lib/radiant_helper_response.rb', line 7 def body @body end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/radiant_helper_response.rb', line 6 def status @status end |
#url ⇒ Object
Returns the value of attribute url.
8 9 10 |
# File 'lib/radiant_helper_response.rb', line 8 def url @url end |
Instance Method Details
#exception ⇒ Object
38 39 40 |
# File 'lib/radiant_helper_response.rb', line 38 def exception Radiant::Helper::InvalidResponseError.new("URL: #{self.url} did not return a valid response! Status: #{self.status}") unless self.success? end |
#has_layout? ⇒ Boolean
28 29 30 31 32 33 34 35 36 |
# File 'lib/radiant_helper_response.rb', line 28 def has_layout? ivar_cache("has_layout") do unless self.body.nil? b = self.body.downcase return ((b.match("<html>") ? true : false) && (b.match("</html>") ? true : false)) end return false end end |
#success? ⇒ Boolean
16 17 18 |
# File 'lib/radiant_helper_response.rb', line 16 def success? self.status == 200 end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/radiant_helper_response.rb', line 20 def to_s self.success? ? self.body : "" end |
#to_str ⇒ Object
24 25 26 |
# File 'lib/radiant_helper_response.rb', line 24 def to_str self.to_s end |