Class: Cnf::Catalog
- Inherits:
-
Object
- Object
- Cnf::Catalog
- Extended by:
- Enumerable, Forwardable
- Defined in:
- lib/cnf/catalog.rb
Class Method Summary collapse
- .data ⇒ Object
- .filter_by_marketplace(marketplace_ids) ⇒ Object
- .find_by_name(name) ⇒ Object
- .find_catalog_by_country_code(country_code) ⇒ Object
- .names ⇒ Object
Instance Method Summary collapse
- #active? ⇒ Boolean
- #country ⇒ Object
- #currency ⇒ Object
- #in?(marketplace_ids) ⇒ Boolean
- #language ⇒ Object
- #marketplace_id ⇒ Object
- #name ⇒ Object
- #supported_parent_offer?(_) ⇒ Boolean
Class Method Details
.data ⇒ Object
24 25 26 |
# File 'lib/cnf/catalog.rb', line 24 def data @data ||= Cnf.amazon.map { |country| new(country.to_h) } end |
.filter_by_marketplace(marketplace_ids) ⇒ Object
67 68 69 |
# File 'lib/cnf/catalog.rb', line 67 def self.filter_by_marketplace(marketplace_ids) Catalog.select { |catalog| catalog.in? marketplace_ids } end |
.find_by_name(name) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/cnf/catalog.rb', line 75 def self.find_by_name(name) return TestCatalog.call if name == 'www.amazon.com-richardson' return AbebooksCatalog.find_by_name(name) if name =~ /abebooks/ return MiraklCatalog.find_by_name(name) if name =~ /libro/ return NearfineCatalog.find_by_name(name) if name =~ /nearfine/ Catalog.find { |catalog| catalog.name == name } end |
.find_catalog_by_country_code(country_code) ⇒ Object
71 72 73 |
# File 'lib/cnf/catalog.rb', line 71 def self.find_catalog_by_country_code(country_code) Catalog.find { |catalog| catalog.country == country_code } end |
.names ⇒ Object
33 34 35 |
# File 'lib/cnf/catalog.rb', line 33 def self.names map(&:name) + Cnf::AbebooksCatalog.names end |
Instance Method Details
#active? ⇒ Boolean
59 60 61 |
# File 'lib/cnf/catalog.rb', line 59 def active? Cnf.active_channels.include? marketplace.country_code end |
#country ⇒ Object
37 38 39 |
# File 'lib/cnf/catalog.rb', line 37 def country marketplace.country_code end |
#currency ⇒ Object
41 42 43 |
# File 'lib/cnf/catalog.rb', line 41 def currency marketplace.currency_code end |
#in?(marketplace_ids) ⇒ Boolean
55 56 57 |
# File 'lib/cnf/catalog.rb', line 55 def in?(marketplace_ids) active? && marketplace_ids.include?(marketplace_id) end |
#language ⇒ Object
63 64 65 |
# File 'lib/cnf/catalog.rb', line 63 def language marketplace.language_code end |
#marketplace_id ⇒ Object
51 52 53 |
# File 'lib/cnf/catalog.rb', line 51 def marketplace_id marketplace.id end |
#name ⇒ Object
29 30 31 |
# File 'lib/cnf/catalog.rb', line 29 def name marketplace.hostname end |
#supported_parent_offer?(_) ⇒ Boolean
45 46 47 |
# File 'lib/cnf/catalog.rb', line 45 def supported_parent_offer?(_) true end |