Class: Pastry
- Inherits:
-
Object
- Object
- Pastry
- Defined in:
- lib/coffee_drinks/pastry.rb
Constant Summary collapse
- @@all =
[]
- @@all_sorted =
[]
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, description = nil) ⇒ Pastry
constructor
A new instance of Pastry.
Constructor Details
#initialize(name, description = nil) ⇒ Pastry
Returns a new instance of Pastry.
8 9 10 11 12 |
# File 'lib/coffee_drinks/pastry.rb', line 8 def initialize (name, description = nil) @name = name @description = description @@all << self end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/coffee_drinks/pastry.rb', line 6 def description @description end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/coffee_drinks/pastry.rb', line 6 def name @name end |
Class Method Details
.all ⇒ Object
14 15 16 |
# File 'lib/coffee_drinks/pastry.rb', line 14 def self.all @@all end |
.sorted_all ⇒ Object
18 19 20 21 |
# File 'lib/coffee_drinks/pastry.rb', line 18 def self.sorted_all self.all.sort_by {|pastry| pastry.name}.each {|instance| @@all_sorted << instance } @@all_sorted end |