Class: RuBing::Response
- Inherits:
-
Object
- Object
- RuBing::Response
- Defined in:
- lib/rubing.rb
Instance Method Summary collapse
- #current_page ⇒ Object
-
#initialize(json, count) ⇒ Response
constructor
A new instance of Response.
- #next_page ⇒ Object
- #offset ⇒ Object
- #previous_page ⇒ Object
- #results ⇒ Object
- #total_pages ⇒ Object
- #total_results ⇒ Object
Constructor Details
#initialize(json, count) ⇒ Response
Returns a new instance of Response.
92 93 94 95 |
# File 'lib/rubing.rb', line 92 def initialize(json, count) @json = json @count = count end |
Instance Method Details
#current_page ⇒ Object
109 110 111 |
# File 'lib/rubing.rb', line 109 def current_page (offset / @count) + 1 end |
#next_page ⇒ Object
117 118 119 |
# File 'lib/rubing.rb', line 117 def next_page current_page < total_pages ? (current_page + 1) : nil end |
#offset ⇒ Object
121 122 123 |
# File 'lib/rubing.rb', line 121 def offset @offset ||= get_offset end |
#previous_page ⇒ Object
113 114 115 |
# File 'lib/rubing.rb', line 113 def previous_page current_page > 1 ? (current_page - 1) : nil end |
#results ⇒ Object
97 98 99 |
# File 'lib/rubing.rb', line 97 def results @results ||= get_results end |
#total_pages ⇒ Object
105 106 107 |
# File 'lib/rubing.rb', line 105 def total_pages total_results / @count end |
#total_results ⇒ Object
101 102 103 |
# File 'lib/rubing.rb', line 101 def total_results @total_results ||= get_total_results end |