Class: PunkyBrewster::Beer
- Inherits:
-
Struct
- Object
- Struct
- PunkyBrewster::Beer
- Defined in:
- lib/punky_brewster/beer.rb
Instance Attribute Summary collapse
-
#abv ⇒ Object
Returns the value of attribute abv.
-
#image_url ⇒ Object
Returns the value of attribute image_url.
-
#name ⇒ Object
Returns the value of attribute name.
-
#price ⇒ Object
Returns the value of attribute price.
Instance Method Summary collapse
- #abv_per_dollar ⇒ Object
-
#valid? ⇒ Boolean
Returns true if all expected values have been set.
Instance Attribute Details
#abv ⇒ Object
Returns the value of attribute abv
2 3 4 |
# File 'lib/punky_brewster/beer.rb', line 2 def abv @abv end |
#image_url ⇒ Object
Returns the value of attribute image_url
2 3 4 |
# File 'lib/punky_brewster/beer.rb', line 2 def image_url @image_url end |
#name ⇒ Object
Returns the value of attribute name
2 3 4 |
# File 'lib/punky_brewster/beer.rb', line 2 def name @name end |
#price ⇒ Object
Returns the value of attribute price
2 3 4 |
# File 'lib/punky_brewster/beer.rb', line 2 def price @price end |
Instance Method Details
#abv_per_dollar ⇒ Object
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.
8 9 10 |
# File 'lib/punky_brewster/beer.rb', line 8 def valid? values.compact.length == members.length end |