Class: RateBeer::Brewery

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

Constant Summary

Constants included from URLs

URLs::BASE_URL, URLs::SEARCH_URL

Instance Attribute Summary collapse

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) ⇒ Brewery

Create RateBeer::Brewery instance.

Requires the RateBeer ID# for the brewery in question. Optionally accepts a name parameter where the name is already known.

Parameters:

  • id (Integer, String)

    ID# for the brewery

  • name (String) (defaults to: nil)

    The name of the specified brewery

  • options (hash)

    Options hash for entity created



31
32
33
34
35
36
37
38
39
# File 'lib/ratebeer/brewery.rb', line 31

def initialize(id, name: nil, **options)
  super
  if options
    @established = options[:established]
    @location    = options[:location]
    @type        = options[:type]
    @status      = options[:status]
  end
end

Instance Attribute Details

#establishedObject (readonly)

Returns the value of attribute established.



20
21
22
# File 'lib/ratebeer/brewery.rb', line 20

def established
  @established
end

#locationObject (readonly)

Returns the value of attribute location.



20
21
22
# File 'lib/ratebeer/brewery.rb', line 20

def location
  @location
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.



9
10
11
12
13
14
15
# File 'lib/ratebeer/brewery.rb', line 9

def self.data_keys
  [:name,
   :type,
   :address,
   :telephone,
   :beers]
end