Class: Thumbnail::Response::Failure
- Inherits:
-
Object
- Object
- Thumbnail::Response::Failure
- Defined in:
- lib/thumbnail/response.rb
Instance Attribute Summary collapse
-
#hpricot ⇒ Object
Returns the value of attribute hpricot.
-
#parsed ⇒ Object
Returns the value of attribute parsed.
-
#xml ⇒ Object
Returns the value of attribute xml.
Instance Method Summary collapse
- #[](arg) ⇒ Object
-
#initialize(opts = {}) ⇒ Failure
constructor
A new instance of Failure.
-
#to_s ⇒ Object
prettily print the errors.
Constructor Details
#initialize(opts = {}) ⇒ Failure
Returns a new instance of Failure.
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/thumbnail/response.rb', line 64 def initialize(opts={}) @hpricot = opts[:hpricot] @xml = opts[:xml] @parsed = {} @parsed[:request_id] = (@hpricot/"RequestId").inner_text @parsed[:errors] = [] (@hpricot/"Errors").each do |e| error = {} error[:code] = (e/"Code").inner_text error[:message] = (e/"Message").inner_text @parsed[:errors] << error end end |
Instance Attribute Details
#hpricot ⇒ Object
Returns the value of attribute hpricot.
62 63 64 |
# File 'lib/thumbnail/response.rb', line 62 def hpricot @hpricot end |
#parsed ⇒ Object
Returns the value of attribute parsed.
62 63 64 |
# File 'lib/thumbnail/response.rb', line 62 def parsed @parsed end |
#xml ⇒ Object
Returns the value of attribute xml.
62 63 64 |
# File 'lib/thumbnail/response.rb', line 62 def xml @xml end |
Instance Method Details
#[](arg) ⇒ Object
83 84 85 |
# File 'lib/thumbnail/response.rb', line 83 def [](arg) @parsed[arg] end |
#to_s ⇒ Object
prettily print the errors.
79 80 81 |
# File 'lib/thumbnail/response.rb', line 79 def to_s @parsed[:errors].collect{|e| "#{e[:code]}: #{e[:message]}"}.join('\n') end |