Class: Tea
- Inherits:
-
Object
- Object
- Tea
- Defined in:
- lib/tea.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#description ⇒ Object
Returns the value of attribute description.
-
#ingredients ⇒ Object
Returns the value of attribute ingredients.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pricing ⇒ Object
Returns the value of attribute pricing.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
- .all ⇒ Object
- .all_teas_in(tea_category) ⇒ Object
- .find_by_ingredient(ingredient) ⇒ Object
- .find_by_name(name) ⇒ Object
- .get_random_tea ⇒ Object
Instance Method Summary collapse
-
#check_for_tea_info ⇒ Object
checks whether or not we’ve already scraped the info about this particular tea object returns true if tea info has already been acquired.
-
#initialize(name) ⇒ Tea
constructor
A new instance of Tea.
Constructor Details
#initialize(name) ⇒ Tea
Returns a new instance of Tea.
9 10 11 12 13 14 15 |
# File 'lib/tea.rb', line 9 def initialize(name) @name = name @@all << self self.description = "" self.ingredients = "" self.pricing = {} end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
6 7 8 |
# File 'lib/tea.rb', line 6 def category @category end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/tea.rb', line 6 def description @description end |
#ingredients ⇒ Object
Returns the value of attribute ingredients.
6 7 8 |
# File 'lib/tea.rb', line 6 def ingredients @ingredients end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/tea.rb', line 5 def name @name end |
#pricing ⇒ Object
Returns the value of attribute pricing.
6 7 8 |
# File 'lib/tea.rb', line 6 def pricing @pricing end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/tea.rb', line 6 def url @url end |
Class Method Details
.all ⇒ Object
17 18 19 |
# File 'lib/tea.rb', line 17 def self.all @@all end |
.all_teas_in(tea_category) ⇒ Object
31 32 33 |
# File 'lib/tea.rb', line 31 def self.all_teas_in(tea_category) @@all.select {|tea| tea.category.name == tea_category} end |
.find_by_ingredient(ingredient) ⇒ Object
35 36 37 |
# File 'lib/tea.rb', line 35 def self.find_by_ingredient(ingredient) @@all.select { |tea| tea.ingredients.include?(ingredient) } end |
.find_by_name(name) ⇒ Object
21 22 23 |
# File 'lib/tea.rb', line 21 def self.find_by_name(name) @@all.detect {|tea| tea.name == name} end |
Instance Method Details
#check_for_tea_info ⇒ Object
checks whether or not we’ve already scraped the info about this particular tea object returns true if tea info has already been acquired
27 28 29 |
# File 'lib/tea.rb', line 27 def check_for_tea_info self.ingredients.length > 0 && self.description.length > 0 && self.pricing.length > 0 end |