class KnittingYarnDeals::YarnDeal
Attributes
availability[RW]
description[RW]
name[RW]
price[RW]
url[RW]
Public Class Methods
all()
click to toggle source
# File lib/knitting_yarn_deals/yarn_deal.rb, line 6 def self.all @@all end
find(id)
click to toggle source
# File lib/knitting_yarn_deals/yarn_deal.rb, line 10 def self.find(id) self.all[id-1] end
new()
click to toggle source
# File lib/knitting_yarn_deals/yarn_deal.rb, line 14 def initialize @name = name @price = price @url = url @description = description @availability = true end
Public Instance Methods
save()
click to toggle source
# File lib/knitting_yarn_deals/yarn_deal.rb, line 22 def save if valid? @@all << self end end
valid?()
click to toggle source
# File lib/knitting_yarn_deals/yarn_deal.rb, line 28 def valid? validate_name end
validate_name()
click to toggle source
# File lib/knitting_yarn_deals/yarn_deal.rb, line 32 def validate_name !@name.strip.empty? end