Class: Cortex::Result
- Inherits:
-
Object
- Object
- Cortex::Result
- Defined in:
- lib/cortex/result.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#next_page ⇒ Object
readonly
Returns the value of attribute next_page.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
-
#prev_page ⇒ Object
readonly
Returns the value of attribute prev_page.
-
#range ⇒ Object
readonly
Returns the value of attribute range.
-
#range_end ⇒ Object
readonly
Returns the value of attribute range_end.
-
#range_start ⇒ Object
readonly
Returns the value of attribute range_start.
-
#raw_headers ⇒ Object
readonly
Returns the value of attribute raw_headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#total_items ⇒ Object
readonly
Returns the value of attribute total_items.
-
#total_pages ⇒ Object
readonly
Returns the value of attribute total_pages.
Instance Method Summary collapse
-
#initialize(body, headers, status) ⇒ Result
constructor
A new instance of Result.
- #is_error? ⇒ Boolean
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
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
3 4 5 |
# File 'lib/cortex/result.rb', line 3 def contents @contents end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
3 4 5 |
# File 'lib/cortex/result.rb', line 3 def errors @errors end |
#next_page ⇒ Object (readonly)
Returns the value of attribute next_page.
3 4 5 |
# File 'lib/cortex/result.rb', line 3 def next_page @next_page end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
3 4 5 |
# File 'lib/cortex/result.rb', line 3 def page @page end |
#per_page ⇒ Object (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_page ⇒ Object (readonly)
Returns the value of attribute prev_page.
3 4 5 |
# File 'lib/cortex/result.rb', line 3 def prev_page @prev_page end |
#range ⇒ Object (readonly)
Returns the value of attribute range.
3 4 5 |
# File 'lib/cortex/result.rb', line 3 def range @range end |
#range_end ⇒ Object (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_start ⇒ Object (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_headers ⇒ Object (readonly)
Returns the value of attribute raw_headers.
3 4 5 |
# File 'lib/cortex/result.rb', line 3 def raw_headers @raw_headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/cortex/result.rb', line 3 def status @status end |
#total_items ⇒ Object (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_pages ⇒ Object (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
13 14 15 |
# File 'lib/cortex/result.rb', line 13 def is_error? @status >= 400 || (@contents.is_a?(Hash) && @contents.errors?) end |