Class: Thumbnail::Response::Failure

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#hpricotObject

Returns the value of attribute hpricot.



62
63
64
# File 'lib/thumbnail/response.rb', line 62

def hpricot
  @hpricot
end

#parsedObject

Returns the value of attribute parsed.



62
63
64
# File 'lib/thumbnail/response.rb', line 62

def parsed
  @parsed
end

#xmlObject

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_sObject

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