Class: WhosGotDirt::Responses::Helpers::LittleSisHelper

Inherits:
WhosGotDirt::Response show all
Defined in:
lib/whos_got_dirt/responses/helpers/little_sis.rb

Direct Known Subclasses

Entity::LittleSis, List::LittleSis

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from WhosGotDirt::Response

Class Attribute Details

.count_fieldObject (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

#countFixnum

Returns the total number of matching results.

Returns:

  • (Fixnum)

    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_messageObject

Returns the error message.



47
48
49
# File 'lib/whos_got_dirt/responses/helpers/little_sis.rb', line 47

def error_message
  parsed_body.strip
end

#pageFixnum

Returns the current page number.

Returns:

  • (Fixnum)

    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_bodyArray<Hash>

Parses the response body.

Returns:

  • (Array<Hash>)

    the parsed 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