Class: BeerAdvocate::Brewery
- Inherits:
-
Object
- Object
- BeerAdvocate::Brewery
- Defined in:
- lib/beer_advocate/brewery.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#beers ⇒ Object
Returns the value of attribute beers.
-
#brewery_url ⇒ Object
Returns the value of attribute brewery_url.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #add_beer(beer) ⇒ Object
-
#initialize(name) ⇒ Brewery
constructor
A new instance of Brewery.
Constructor Details
#initialize(name) ⇒ Brewery
Returns a new instance of Brewery.
6 7 8 9 10 |
# File 'lib/beer_advocate/brewery.rb', line 6 def initialize(name) @@all << self @name = name @beers = [] end |
Instance Attribute Details
#beers ⇒ Object
Returns the value of attribute beers.
2 3 4 |
# File 'lib/beer_advocate/brewery.rb', line 2 def beers @beers end |
#brewery_url ⇒ Object
Returns the value of attribute brewery_url.
2 3 4 |
# File 'lib/beer_advocate/brewery.rb', line 2 def brewery_url @brewery_url end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/beer_advocate/brewery.rb', line 2 def name @name end |
Class Method Details
.all ⇒ Object
16 17 18 |
# File 'lib/beer_advocate/brewery.rb', line 16 def self.all @@all end |
.find_brewery(brewery) ⇒ Object
20 21 22 |
# File 'lib/beer_advocate/brewery.rb', line 20 def self.find_brewery(brewery) self.all.find {|x| x.name == brewery} end |
.find_or_create(brewery) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/beer_advocate/brewery.rb', line 24 def self.find_or_create(brewery) if self.find_brewery(brewery) == nil self.new(brewery) else self.find_brewery(brewery) end end |
Instance Method Details
#add_beer(beer) ⇒ Object
12 13 14 |
# File 'lib/beer_advocate/brewery.rb', line 12 def add_beer(beer) beers << beer end |