Class: Countir::Result
- Inherits:
-
Object
- Object
- Countir::Result
- Extended by:
- Forwardable
- Defined in:
- lib/countir/result.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #data ⇒ Object
- #data? ⇒ Boolean
-
#initialize(response, resource_class = nil) ⇒ Result
constructor
A new instance of Result.
- #next_offset ⇒ Object
Constructor Details
#initialize(response, resource_class = nil) ⇒ Result
Returns a new instance of Result.
7 8 9 10 |
# File 'lib/countir/result.rb', line 7 def initialize(response, resource_class = nil) @response = response @resource_class = resource_class end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/countir/result.rb', line 5 def response @response end |
Instance Method Details
#data ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/countir/result.rb', line 18 def data @data ||= begin if data? data = JSON.parse(self.body) if @resource_class @resource_class.response_schema(data) else data end end end end |
#data? ⇒ Boolean
14 15 16 |
# File 'lib/countir/result.rb', line 14 def data? !(self.body.nil? || self.body.empty?) end |
#next_offset ⇒ Object
32 33 34 35 36 |
# File 'lib/countir/result.rb', line 32 def next_offset if data? JSON.parse(self.body)["next_offset"] rescue nil end end |