class YahooShoppingSearch::Responses::Base

Public Class Methods

new(body, params = {}) click to toggle source

@param body [String] @param params [Hash]

# File lib/yahoo_shopping_search/responses/base.rb, line 10
def initialize(body, params = {})
  @body = JSON.parse(body)
  @params = params
end

Public Instance Methods

[](index) click to toggle source

@param index [Integer] @return [YahooShoppingSearch::Resources::Base | nil]

# File lib/yahoo_shopping_search/responses/base.rb, line 49
def [](index)
  items[index]
end
body() click to toggle source

@return [Hash]

# File lib/yahoo_shopping_search/responses/base.rb, line 16
def body
  @body
end
each(&block) click to toggle source

@note Implementation for Enumerable

# File lib/yahoo_shopping_search/responses/base.rb, line 26
def each(&block)
  items.each(&block)
end
items() click to toggle source

@return [Array<YahooShoppingSearch::Resources::Base>]

# File lib/yahoo_shopping_search/responses/base.rb, line 31
def items
  (sources || []).map do |source|
    resource_class.new(source)
  end
end
last() click to toggle source

@return [YahooShoppingSearch::Resources::Base | nil]

# File lib/yahoo_shopping_search/responses/base.rb, line 54
def last
  items.last
end
params() click to toggle source

@return [Hash]

# File lib/yahoo_shopping_search/responses/base.rb, line 21
def params
  @params
end
resource_class() click to toggle source

Specify class name

# File lib/yahoo_shopping_search/responses/base.rb, line 43
def resource_class
  raise NotImplementedError
end
sources() click to toggle source

Specify class name

# File lib/yahoo_shopping_search/responses/base.rb, line 38
def sources
  raise NotImplementedError
end