Class: Pastry

Inherits:
Object
  • Object
show all
Defined in:
lib/coffee_drinks/pastry.rb

Constant Summary collapse

@@all =
[]
@@all_sorted =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#descriptionObject

Returns the value of attribute description.



6
7
8
# File 'lib/coffee_drinks/pastry.rb', line 6

def description
  @description
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/coffee_drinks/pastry.rb', line 6

def name
  @name
end

Class Method Details

.allObject



14
15
16
# File 'lib/coffee_drinks/pastry.rb', line 14

def self.all
    @@all
end

.sorted_allObject



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