Class: PunkyBrewster::Beer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#abvObject

Returns the value of attribute abv

Returns:

  • (Object)

    the current value of abv



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

def abv
  @abv
end

#image_urlObject

Returns the value of attribute image_url

Returns:

  • (Object)

    the current value of image_url



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

def image_url
  @image_url
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



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

def name
  @name
end

#priceObject

Returns the value of attribute price

Returns:

  • (Object)

    the current value of price



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

def price
  @price
end

Instance Method Details

#abv_per_dollarObject



3
4
5
# File 'lib/punky_brewster/beer.rb', line 3

def abv_per_dollar
  (abv.to_f / price).round(2)
end

#valid?Boolean

Returns true if all expected values have been set.

Returns:

  • (Boolean)


8
9
10
# File 'lib/punky_brewster/beer.rb', line 8

def valid?
  values.compact.length == members.length
end