class SimpleMarketplace::Product

Attributes

code[R]
name[R]
price[R]

Public Class Methods

create(*args) click to toggle source

Fills the products database

# File lib/simple_marketplace/product.rb, line 12
def self.create(*args)
  args.each do |hash|
    @@all[hash[:code]] = Product.new(hash[:code], hash[:name], hash[:price])
  end
end
get_by_code(code) click to toggle source

returns product with the code

# File lib/simple_marketplace/product.rb, line 19
def self.get_by_code(code)
  @@all[code]
end
new(code, name, price) click to toggle source
# File lib/simple_marketplace/product.rb, line 7
def initialize(code, name, price)
  @code, @name, @price = code, name, price
end

Public Instance Methods

==(other) click to toggle source

checks equality

# File lib/simple_marketplace/product.rb, line 29
def ==(other)
  return code == other.code, name == other.name, price: other.price
end
to_s() click to toggle source

pretty print

# File lib/simple_marketplace/product.rb, line 24
def to_s
  "Product(code: #{@code}, name: #{@name}, price: #{@price})"
end