Class: InsoundApi::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Response

Returns a new instance of Response.



9
10
11
12
13
14
# File 'lib/insound_api/response.rb', line 9

def initialize(opts={})
  @request = opts[:request]
  @raw_xml = opts[:raw_xml]
  @doc = Nokogiri::XML(@raw_xml)
  @results = Results.new(@doc)
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



7
8
9
# File 'lib/insound_api/response.rb', line 7

def doc
  @doc
end

#raw_xmlObject (readonly)

Returns the value of attribute raw_xml.



7
8
9
# File 'lib/insound_api/response.rb', line 7

def raw_xml
  @raw_xml
end

#requestObject (readonly)

Returns the value of attribute request.



7
8
9
# File 'lib/insound_api/response.rb', line 7

def request
  @request
end

#resultsObject (readonly)

Returns the value of attribute results.



7
8
9
# File 'lib/insound_api/response.rb', line 7

def results
  @results
end

Instance Method Details

#errorsObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/insound_api/response.rb', line 20

def errors
  unless @errors
    @errors = doc.css('errors request_error').map{ |node|
      code = node.css('error_code').first.inner_html
      text = node.css('error_text').first.inner_html
      {:code => code, :text => text}
    }
  end
  @errors
end

#errors?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/insound_api/response.rb', line 16

def errors?
  errors.any?
end