Class: Drink
- Inherits:
-
Object
- Object
- Drink
- Defined in:
- lib/coffee_drinks/drink.rb
Constant Summary collapse
- @@all =
[]
- @@milk =
[]
- @@no_milk =
[]
- @@all_sorted =
[]
- @@milk_sorted =
[]
- @@no_milk_sorted =
[]
Instance Attribute Summary collapse
-
#cup ⇒ Object
Returns the value of attribute cup.
-
#description ⇒ Object
Returns the value of attribute description.
-
#milk ⇒ Object
Returns the value of attribute milk.
-
#name ⇒ Object
Returns the value of attribute name.
-
#ratio ⇒ Object
Returns the value of attribute ratio.
Class Method Summary collapse
- .all ⇒ Object
- .milk ⇒ Object
- .no_milk ⇒ Object
- .sorted_all ⇒ Object
- .sorted_milk ⇒ Object
- .sorted_no_milk ⇒ Object
Instance Method Summary collapse
-
#initialize(name, milk = "", description, ratio, cup) ⇒ Drink
constructor
A new instance of Drink.
Constructor Details
#initialize(name, milk = "", description, ratio, cup) ⇒ Drink
Returns a new instance of Drink.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/coffee_drinks/drink.rb', line 12 def initialize (name, milk = "", description, ratio, cup) @name = name @milk = milk @description = description @ratio = ratio @cup = cup @@all << self @@milk << self if milk == "yes" @@no_milk << self if milk == "no" end |
Instance Attribute Details
#cup ⇒ Object
Returns the value of attribute cup.
10 11 12 |
# File 'lib/coffee_drinks/drink.rb', line 10 def cup @cup end |
#description ⇒ Object
Returns the value of attribute description.
10 11 12 |
# File 'lib/coffee_drinks/drink.rb', line 10 def description @description end |
#milk ⇒ Object
Returns the value of attribute milk.
10 11 12 |
# File 'lib/coffee_drinks/drink.rb', line 10 def milk @milk end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/coffee_drinks/drink.rb', line 10 def name @name end |
#ratio ⇒ Object
Returns the value of attribute ratio.
10 11 12 |
# File 'lib/coffee_drinks/drink.rb', line 10 def ratio @ratio end |
Class Method Details
.all ⇒ Object
24 25 26 |
# File 'lib/coffee_drinks/drink.rb', line 24 def self.all @@all end |
.milk ⇒ Object
28 29 30 |
# File 'lib/coffee_drinks/drink.rb', line 28 def self.milk @@milk end |
.no_milk ⇒ Object
32 33 34 |
# File 'lib/coffee_drinks/drink.rb', line 32 def self.no_milk @@no_milk end |
.sorted_all ⇒ Object
36 37 38 39 |
# File 'lib/coffee_drinks/drink.rb', line 36 def self.sorted_all self.all.sort_by {|drink| drink.name}.each {|instance| @@all_sorted << instance } @@all_sorted end |
.sorted_milk ⇒ Object
41 42 43 44 |
# File 'lib/coffee_drinks/drink.rb', line 41 def self.sorted_milk self.milk.sort_by {|drink| drink.name}.each {|instance| @@milk_sorted << instance } @@milk_sorted end |
.sorted_no_milk ⇒ Object
47 48 49 50 |
# File 'lib/coffee_drinks/drink.rb', line 47 def self.sorted_no_milk self.no_milk.sort_by {|drink| drink.name}.each {|instance| @@no_milk_sorted << instance } @@no_milk_sorted end |