Class: Goods::Catalog

Inherits:
Object
  • Object
show all
Defined in:
lib/goods/catalog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Catalog

Returns a new instance of Catalog.



5
6
7
8
9
10
11
# File 'lib/goods/catalog.rb', line 5

def initialize(params)
  if params[:string]
    from_string(params[:string], params[:url], params[:encoding])
  else
    raise ArgumentError, "should provide either :string or :url param"
  end
end

Instance Attribute Details

#categoriesObject (readonly)

Returns the value of attribute categories.



3
4
5
# File 'lib/goods/catalog.rb', line 3

def categories
  @categories
end

#currenciesObject (readonly)

Returns the value of attribute currencies.



3
4
5
# File 'lib/goods/catalog.rb', line 3

def currencies
  @currencies
end

#offersObject (readonly)

Returns the value of attribute offers.



3
4
5
# File 'lib/goods/catalog.rb', line 3

def offers
  @offers
end

Instance Method Details

#convert_currency(other_currency) ⇒ Object



18
19
20
# File 'lib/goods/catalog.rb', line 18

def convert_currency(other_currency)
  @offers.convert_currency(other_currency)
end

#dateObject



22
23
24
# File 'lib/goods/catalog.rb', line 22

def date
  @xml.generation_date
end

#prune(level) ⇒ Object



13
14
15
16
# File 'lib/goods/catalog.rb', line 13

def prune(level)
  @offers.prune_categories(level)
  @categories.prune(level)
end