Class: Openfoodfacts::Category
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- Openfoodfacts::Category
- Defined in:
- lib/openfoodfacts/category.rb
Constant Summary collapse
- LOCALE_PATHS =
TODO: Add more locales
{ 'fr' => 'categories', 'uk' => 'categories', 'us' => 'categories', 'world' => 'categories' }
Class Method Summary collapse
-
.all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN) ⇒ Object
Get categories.
Instance Method Summary collapse
-
#products(page: -1)) ⇒ Object
Get products with category.
Class Method Details
.all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN) ⇒ Object
Get categories
18 19 20 21 22 |
# File 'lib/openfoodfacts/category.rb', line 18 def all(locale: DEFAULT_LOCALE, domain: DEFAULT_DOMAIN) if path = LOCALE_PATHS[locale] Product.(self, "https://#{locale}.#{domain}/#{path}") end end |
Instance Method Details
#products(page: -1)) ⇒ Object
Get products with category
28 29 30 |
# File 'lib/openfoodfacts/category.rb', line 28 def products(page: -1) Product.from_website_page(url, page: page, products_count: products_count) if url end |