Sha256: 1cac942844b7fc3c52f3386622ca18c391b74de38a61c914a8a886e7f9fd8e59
Contents?: true
Size: 1.7 KB
Versions: 3
Compression:
Stored size: 1.7 KB
Contents
class FindDeals::Deal attr_accessor :title, :location, :url, :price, :promotion, :about, :city_id, :category_id @@all = [] def initialize (title: nil, url: nil, location: nil, price: 0, promotion: 0, about: nil, category_id: 1, city_id: 1) @@all << self @title = title @location = location @url = url @price = price @promotion = promotion @about = about @category_id = category_id @city_id = city_id end def self.all @@all end def print puts "====================================================================" puts "#{self.title.upcase}" puts "#{self.location}" puts "$#{self.price.to_i} - UP TO #{self.promotion.to_i}% OFF" puts "====================================================================" end def print_about_details puts "====================================================================" puts "#{self.title.upcase}" puts "====================================================================" puts "#{self.about}" puts "" puts "BUY NOW AT #{self.url}" puts "====================================================================" end def save(user_id) SavedDeals.find_or_create_by( title: self.title, location: self.location, url: self.url, price: self.price, promotion: self.promotion, about: self.about, category_id: self.category_id, city_id: self.city_id, user_id: user_id ) end def self.reset_all @@all.clear end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
find_deals-0.1.2 | lib/find_deals/deals.rb |
find_deals-0.1.1 | lib/find_deals/deals.rb |
find_deals-0.1.0 | lib/find_deals/deals.rb |