Sha256: 0a9f5d3b03841c6804423e709e8fc0498cc69a74b72f43e271e5606c9e7fc3d7

Contents?: true

Size: 960 Bytes

Versions: 1

Compression:

Stored size: 960 Bytes

Contents

module WhosGotDirt
  module Responses
    module Helpers
      class LittleSisHelper < Response
        class << self
          # @!attribute [r] count_field
          #   @return [Hash] the field storing the number of results
          attr_reader :count_field
        end

        # Parses the response body.
        #
        # @return [Array<Hash>] the parsed response body
        def parse_body
          Nori.new.parse(body)['Response']
        end

        # Returns the total number of matching results.
        #
        # @return [Fixnum] the total number of matching results
        def count
          Integer(parsed_body['Meta']['TotalCount'] || parsed_body['Meta']['ResultCount'][self.class.count_field])
        end

        # Returns the current page number.
        #
        # @return [Fixnum] the current page number
        def page
          Integer(parsed_body['Meta']['Parameters']['page'] || 1)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whos_got_dirt-0.0.2 lib/whos_got_dirt/responses/helpers/little_sis.rb