Class: Twoffein::Drink
- Inherits:
-
Object
- Object
- Twoffein::Drink
- Defined in:
- lib/twoffein-client/drink.rb
Instance Attribute Summary collapse
-
#brand ⇒ Object
readonly
Returns the value of attribute brand.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(drink) ⇒ Object
-
#initialize(name, key = nil, brand = false) ⇒ Drink
constructor
A new instance of Drink.
- #to_s ⇒ Object
Constructor Details
#initialize(name, key = nil, brand = false) ⇒ Drink
Returns a new instance of Drink.
7 8 9 10 11 |
# File 'lib/twoffein-client/drink.rb', line 7 def initialize(name, key=nil, brand=false) @name = name.to_s @key = (key ? key : key_of(name)).to_sym @brand = !!brand end |
Instance Attribute Details
#brand ⇒ Object (readonly)
Returns the value of attribute brand.
5 6 7 |
# File 'lib/twoffein-client/drink.rb', line 5 def brand @brand end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/twoffein-client/drink.rb', line 5 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/twoffein-client/drink.rb', line 5 def name @name end |
Instance Method Details
#==(drink) ⇒ Object
17 18 19 20 21 |
# File 'lib/twoffein-client/drink.rb', line 17 def ==(drink) name == drink.name && key == drink.key && brand == drink.brand end |
#to_s ⇒ Object
13 14 15 |
# File 'lib/twoffein-client/drink.rb', line 13 def to_s "#@name (#@key)" end |