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