Class: OnTapIbc::Beer

Inherits:
Object
  • Object
show all
Defined in:
lib/on_tap_ibc/beer.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(beer_hash) ⇒ Beer

Returns a new instance of Beer.



6
7
8
9
# File 'lib/on_tap_ibc/beer.rb', line 6

def initialize(beer_hash)
  beer_hash.each {|key, value| self.send(("#{key}="), value)}
  @@all << self
end

Instance Attribute Details

#abvObject

Returns the value of attribute abv.



2
3
4
# File 'lib/on_tap_ibc/beer.rb', line 2

def abv
  @abv
end

#addl1Object

Returns the value of attribute addl1.



2
3
4
# File 'lib/on_tap_ibc/beer.rb', line 2

def addl1
  @addl1
end

#long_descObject

Returns the value of attribute long_desc.



2
3
4
# File 'lib/on_tap_ibc/beer.rb', line 2

def long_desc
  @long_desc
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/on_tap_ibc/beer.rb', line 2

def name
  @name
end

#short_descObject

Returns the value of attribute short_desc.



2
3
4
# File 'lib/on_tap_ibc/beer.rb', line 2

def short_desc
  @short_desc
end

#styleObject

Returns the value of attribute style.



2
3
4
# File 'lib/on_tap_ibc/beer.rb', line 2

def style
  @style
end

Class Method Details

.allObject



28
29
30
# File 'lib/on_tap_ibc/beer.rb', line 28

def self.all
  @@all
end

.assign_beer(selected_tap) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/on_tap_ibc/beer.rb', line 15

def self.assign_beer(selected_tap)
  @beer_detail_hash = OnTapIbc::Scraper.beer_details.find{|k, v| k == selected_tap.name.upcase }
    if @beer_detail_hash != nil
      @beer_detail_hash[1].each do |attribute, data|
        selected_tap.send(("#{attribute}="), data)
      end
    end
end

.create_from_menu(current_beers) ⇒ Object



11
12
13
# File 'lib/on_tap_ibc/beer.rb', line 11

def self.create_from_menu(current_beers)
  current_beers.each {|beer| self.new(beer)}
end