Class: Tea

Inherits:
Object
  • Object
show all
Defined in:
lib/coffee_drinks/tea.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, flavor = nil, varieties = nil) ⇒ Tea

Returns a new instance of Tea.



8
9
10
11
12
13
14
# File 'lib/coffee_drinks/tea.rb', line 8

def initialize (name, description = nil, flavor = nil, varieties = nil)
    @name = name
    @description = description
    @flavor = flavor
    @varieties = varieties
    @@all << self
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#flavorObject

Returns the value of attribute flavor.



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

def flavor
  @flavor
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#varietiesObject

Returns the value of attribute varieties.



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

def varieties
  @varieties
end

Class Method Details

.allObject



16
17
18
# File 'lib/coffee_drinks/tea.rb', line 16

def self.all
    @@all
end

.sorted_allObject



20
21
22
23
# File 'lib/coffee_drinks/tea.rb', line 20

def self.sorted_all
    self.all.sort_by {|tea| tea.name}.each {|instance| @@all_sorted << instance }
    @@all_sorted
end