Class: BeerAdvocate::Style

Inherits:
Object
  • Object
show all
Defined in:
lib/beer_advocate/style.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#beersObject

Returns the value of attribute beers.



2
3
4
# File 'lib/beer_advocate/style.rb', line 2

def beers
  @beers
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/beer_advocate/style.rb', line 2

def name
  @name
end

#style_urlObject

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

.allObject



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