class Glossier::Product

Attributes

catagory[RW]
description[RW]
name[RW]
price[RW]
url[RW]

Public Class Methods

all() click to toggle source
# File lib/glossier/product.rb, line 25
def self.all
  @@all
end
new(attributes_hash) click to toggle source
# File lib/glossier/product.rb, line 8
def initialize(attributes_hash)
  @name = attributes_hash.values_at(:name).join
  @catagory = attributes_hash.values_at(:catagory).join
  @description = attributes_hash.values_at(:description ).join
  @price = attributes_hash.values_at(:price).join
  @url = attributes_hash.values_at(:url).join
  catagory_check
  add_to_catagory(self)
  self.catagory.add_product(self)
  add_to_all
  add_to_catagory(self)
  self.catagory.add_product(self)

  @@all << self

end

Public Instance Methods

add_to_all() click to toggle source
# File lib/glossier/product.rb, line 45
def add_to_all
  if self.catagory != "all"
    self.catagory = "all"
  end
end
add_to_catagory(product) click to toggle source
# File lib/glossier/product.rb, line 33
def add_to_catagory(product)
  catagory_instance = Glossier::Catagory.find_by_name(product.catagory)
  product.catagory = catagory_instance
end
catagory_check() click to toggle source
# File lib/glossier/product.rb, line 51
def catagory_check
  if self.catagory == " " || self.catagory == ""
    self.catagory = "all"
  end
end
clear() click to toggle source
# File lib/glossier/product.rb, line 29
def clear
  @@all.clear
end
list_attributes() click to toggle source
# File lib/glossier/product.rb, line 38
def list_attributes
  puts "#{self.name}".colorize(:light_magenta)
  puts "#{self.description}"
  puts "$#{self.price}".colorize(:light_magenta)
  puts "#{self.url}".colorize(:light_magenta)
end