Class: WhosGotDirt::Responses::Helpers::LittleSisHelper
- Inherits:
-
WhosGotDirt::Response
- Object
- SimpleDelegator
- WhosGotDirt::Response
- WhosGotDirt::Responses::Helpers::LittleSisHelper
- Defined in:
- lib/whos_got_dirt/responses/helpers/little_sis.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.count_field ⇒ Object
readonly
Returns the value of attribute count_field.
Class Method Summary collapse
Instance Method Summary collapse
-
#count ⇒ Fixnum
Returns the total number of matching results.
-
#error_message ⇒ Object
Returns the error message.
-
#page ⇒ Fixnum
Returns the current page number.
-
#parse_body ⇒ Array<Hash>
Parses the response body.
Constructor Details
This class inherits a constructor from WhosGotDirt::Response
Class Attribute Details
.count_field ⇒ Object (readonly)
Returns the value of attribute count_field.
8 9 10 |
# File 'lib/whos_got_dirt/responses/helpers/little_sis.rb', line 8 def count_field @count_field end |
Class Method Details
.date_formatter(property, path) ⇒ Object
11 12 13 14 15 |
# File 'lib/whos_got_dirt/responses/helpers/little_sis.rb', line 11 def date_formatter(property, path) return lambda{|data| [property, JsonPointer.new(data, path).value.sub(' ', 'T') + 'Z'] } end |
.integer_formatter(property, path) ⇒ Object
18 19 20 21 22 |
# File 'lib/whos_got_dirt/responses/helpers/little_sis.rb', line 18 def integer_formatter(property, path) return lambda{|data| [property, Integer(JsonPointer.new(data, path).value)] } end |
Instance Method Details
#count ⇒ Fixnum
Returns the total number of matching results.
35 36 37 |
# File 'lib/whos_got_dirt/responses/helpers/little_sis.rb', line 35 def count Integer(parsed_body['Meta']['TotalCount'] || parsed_body['Meta']['ResultCount'][self.class.count_field]) end |
#error_message ⇒ Object
Returns the error message.
47 48 49 |
# File 'lib/whos_got_dirt/responses/helpers/little_sis.rb', line 47 def parsed_body.strip end |
#page ⇒ Fixnum
Returns the current page number.
42 43 44 |
# File 'lib/whos_got_dirt/responses/helpers/little_sis.rb', line 42 def page Integer(parsed_body['Meta']['Parameters']['page'] || 1) end |
#parse_body ⇒ Array<Hash>
Parses the response body.
28 29 30 |
# File 'lib/whos_got_dirt/responses/helpers/little_sis.rb', line 28 def parse_body Nori.new.parse(body)['Response'] end |