Class: RateBeer::Beer

Inherits:
Object
  • Object
show all
Includes:
Scraping, URLs
Defined in:
lib/ratebeer/beer.rb

Constant Summary

Constants included from URLs

URLs::BASE_URL, URLs::SEARCH_URL

Instance Attribute Summary

Attributes included from Scraping

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from URLs

#beer_url, #brewery_url, #country_url, #region_url, #review_url, #style_beers_url, #style_url

Methods included from Scraping

#==, #fix_characters, #full_details, included, #inspect, nbsp, noko_doc, #page_count, #pagination?, #post_request, #symbolize_text, #to_s, #url

Constructor Details

#initialize(id, name: nil, **options) ⇒ Beer

Create RateBeer::Beer instance.

Requires the RateBeer ID# for the beer in question.

Parameters:

  • id (Integer, String)

    ID# of beer to retrieve

  • name (String) (defaults to: nil)

    Name of the beer to which ID# relates if known

  • options (hash)

    Options hash for entity created



36
37
38
# File 'lib/ratebeer/beer.rb', line 36

def initialize(id, name: nil, **options)
  super
end

Class Method Details

.data_keysObject

Each key represents an item of data accessible for each beer, and defines dynamically a series of methods for accessing this data.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ratebeer/beer.rb', line 12

def self.data_keys
  [:name,
   :brewery, 
   :style, 
   :glassware, 
   :availability, 
   :abv, 
   :calories, 
   :description,
   :retired,
   :rating]
end

Instance Method Details

#reviews(order: :most_recent, limit: 10) ⇒ Object

Return reviews of this beer.



42
43
44
# File 'lib/ratebeer/beer.rb', line 42

def reviews(order: :most_recent, limit: 10)
  Review.retrieve(self, order: order, limit: limit)
end