class Tea

Attributes

category[RW]
description[RW]
ingredients[RW]
name[R]
pricing[RW]
url[RW]

Public Class Methods

all() click to toggle source
# File lib/tea.rb, line 17
def self.all 
    @@all
end
all_teas_in(tea_category) click to toggle source
# 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) click to toggle source
# File lib/tea.rb, line 35
def self.find_by_ingredient(ingredient)
    @@all.select { |tea| tea.ingredients.include?(ingredient) } 
end
find_by_name(name) click to toggle source
# File lib/tea.rb, line 21
def self.find_by_name(name)
    @@all.detect {|tea| tea.name == name}
end
get_random_tea() click to toggle source
# File lib/tea.rb, line 39
def self.get_random_tea
    rand_tea  = Tea.all.sample 
    rand_tea.name 
end
new(name) click to toggle source
# File lib/tea.rb, line 9
def initialize(name)
    @name = name
    @@all << self 
    self.description = ""
    self.ingredients = "" 
    self.pricing = {} 
end

Public Instance Methods

check_for_tea_info() click to toggle source

checks whether or not we've already scraped the info about this particular tea object returns true if tea info has already been acquired

# File lib/tea.rb, line 27
def check_for_tea_info
    self.ingredients.length > 0 && self.description.length > 0 && self.pricing.length > 0 
end