class LoveOfTea::Tea
Attributes
caffeine[RW]
description[RW]
name[RW]
price[RW]
type[RW]
url[RW]
Public Class Methods
all()
click to toggle source
# File lib/love_of_tea/tea.rb, line 21 def self.all @@all end
black()
click to toggle source
# File lib/love_of_tea/tea.rb, line 43 def self.black @@all.reject {|tea| tea.type != "Black"} end
cart()
click to toggle source
# File lib/love_of_tea/tea.rb, line 64 def self.cart @@cart end
chai()
click to toggle source
# File lib/love_of_tea/tea.rb, line 51 def self.chai @@all.reject {|tea| tea.type != "Chai"} end
clear_all()
click to toggle source
# File lib/love_of_tea/tea.rb, line 25 def self.clear_all @@all.clear end
create_from_collection(tea_url)
click to toggle source
# File lib/love_of_tea/tea.rb, line 29 def self.create_from_collection(tea_url) LoveOfTea::Scraper.scrape_by_tea_url(tea_url).each do |teahash| self.new(teahash) end end
green()
click to toggle source
# File lib/love_of_tea/tea.rb, line 35 def self.green @@all.reject {|tea| tea.type != "Green"} end
herbal()
click to toggle source
# File lib/love_of_tea/tea.rb, line 47 def self.herbal @@all.reject {|tea| tea.type != "Herbal"} end
new(teahash)
click to toggle source
# File lib/love_of_tea/tea.rb, line 11 def initialize(teahash) @name = teahash[:name] @type = teahash[:type] @price = teahash[:price] ? teahash[:price] : teahash[:price2] @description = teahash[:description] @caffeine = if teahash[:type] == "Green" then "medium" elsif teahash[:type] == "White" then "low" elsif teahash[:type] == "Black" || teahash[:type] == "Chai" then "high" else nil end @url = teahash[:url] @@all << self end
price_by_name(teaname)
click to toggle source
# File lib/love_of_tea/tea.rb, line 55 def self.price_by_name(teaname) tea = @@all.detect {|tea| tea.name == teaname} tea.price end
white()
click to toggle source
# File lib/love_of_tea/tea.rb, line 39 def self.white @@all.reject {|tea| tea.type != "White"} end
Public Instance Methods
save()
click to toggle source
# File lib/love_of_tea/tea.rb, line 60 def save @@cart << self end