Class: Cortex::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/cortex/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body, headers, status) ⇒ Result

Returns a new instance of Result.



5
6
7
8
9
10
11
# File 'lib/cortex/result.rb', line 5

def initialize(body, headers, status)
  @contents = body
  @raw_headers = headers
  @status = status
  parse_headers(headers)
  @errors = find_errors
end

Instance Attribute Details

#contentsObject (readonly)

Returns the value of attribute contents.



3
4
5
# File 'lib/cortex/result.rb', line 3

def contents
  @contents
end

#errorsObject (readonly)

Returns the value of attribute errors.



3
4
5
# File 'lib/cortex/result.rb', line 3

def errors
  @errors
end

#next_pageObject (readonly)

Returns the value of attribute next_page.



3
4
5
# File 'lib/cortex/result.rb', line 3

def next_page
  @next_page
end

#pageObject (readonly)

Returns the value of attribute page.



3
4
5
# File 'lib/cortex/result.rb', line 3

def page
  @page
end

#per_pageObject (readonly)

Returns the value of attribute per_page.



3
4
5
# File 'lib/cortex/result.rb', line 3

def per_page
  @per_page
end

#prev_pageObject (readonly)

Returns the value of attribute prev_page.



3
4
5
# File 'lib/cortex/result.rb', line 3

def prev_page
  @prev_page
end

#rangeObject (readonly)

Returns the value of attribute range.



3
4
5
# File 'lib/cortex/result.rb', line 3

def range
  @range
end

#range_endObject (readonly)

Returns the value of attribute range_end.



3
4
5
# File 'lib/cortex/result.rb', line 3

def range_end
  @range_end
end

#range_startObject (readonly)

Returns the value of attribute range_start.



3
4
5
# File 'lib/cortex/result.rb', line 3

def range_start
  @range_start
end

#raw_headersObject (readonly)

Returns the value of attribute raw_headers.



3
4
5
# File 'lib/cortex/result.rb', line 3

def raw_headers
  @raw_headers
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/cortex/result.rb', line 3

def status
  @status
end

#total_itemsObject (readonly)

Returns the value of attribute total_items.



3
4
5
# File 'lib/cortex/result.rb', line 3

def total_items
  @total_items
end

#total_pagesObject (readonly)

Returns the value of attribute total_pages.



3
4
5
# File 'lib/cortex/result.rb', line 3

def total_pages
  @total_pages
end

Instance Method Details

#is_error?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/cortex/result.rb', line 13

def is_error?
  @status >= 400 || (@contents.is_a?(Hash) && @contents.errors?)
end