Class: Srchio::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/srchio/response.rb', line 5

def initialize(response)
  puts response.body
  r = response.parsed_response
  @success = r['success']
  if r['success'].nil?
    @success = false
  end
  @error = r['error']
  @pages = r['pages']
  @current_page = r['current_page']
  @next_page = r['next_page']
  @previous_page = r['previous_page']
  
  if r['results'].is_a?(Array)
    @results = []
    r['results'].each do |result|
      if result['tag']
        @results << Srchio::Tag.new(result)
      else
        @results << Srchio::Result.new(result)
      end
    end
  end
end

Instance Attribute Details

#current_pageObject

Returns the value of attribute current_page.



3
4
5
# File 'lib/srchio/response.rb', line 3

def current_page
  @current_page
end

#errorObject

Returns the value of attribute error.



3
4
5
# File 'lib/srchio/response.rb', line 3

def error
  @error
end

#pagesObject

Returns the value of attribute pages.



3
4
5
# File 'lib/srchio/response.rb', line 3

def pages
  @pages
end

#previous_pageObject

Returns the value of attribute previous_page.



3
4
5
# File 'lib/srchio/response.rb', line 3

def previous_page
  @previous_page
end

#resultsObject

Returns the value of attribute results.



3
4
5
# File 'lib/srchio/response.rb', line 3

def results
  @results
end

#successObject

Returns the value of attribute success.



3
4
5
# File 'lib/srchio/response.rb', line 3

def success
  @success
end