Class: Xsys::Model::Product

Inherits:
Object
  • Object
show all
Defined in:
lib/xsys/model/product.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Product

Returns a new instance of Product.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/xsys/model/product.rb', line 8

def initialize(attributes={})
  attributes.each do |k,v|
    if k == 'category'
      @category = ProductCategory.new(v)
    elsif k == 'provider'
      @provider = ProductProvider.new(v)
    elsif k == 'stocks'
      @stocks = v.map { |s| Stock.new(s) }
    else
      self.send("#{k}=", v)
    end
  end
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def active
  @active
end

#categoryObject

Returns the value of attribute category.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def category
  @category
end

#costObject

Returns the value of attribute cost.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def cost
  @cost
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def id
  @id
end

#list_price_1Object

Returns the value of attribute list_price_1.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def list_price_1
  @list_price_1
end

#list_price_35Object

Returns the value of attribute list_price_35.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def list_price_35
  @list_price_35
end

#list_price_6Object

Returns the value of attribute list_price_6.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def list_price_6
  @list_price_6
end

#markup_1Object

Returns the value of attribute markup_1.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def markup_1
  @markup_1
end

#markup_35Object

Returns the value of attribute markup_35.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def markup_35
  @markup_35
end

#markup_6Object

Returns the value of attribute markup_6.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def markup_6
  @markup_6
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def name
  @name
end

#providerObject

Returns the value of attribute provider.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def provider
  @provider
end

#remaining_quantityObject

Returns the value of attribute remaining_quantity.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def remaining_quantity
  @remaining_quantity
end

#salesObject

Returns the value of attribute sales.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def sales
  @sales
end

#sellableObject

Returns the value of attribute sellable.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def sellable
  @sellable
end

#stocksObject

Returns the value of attribute stocks.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def stocks
  @stocks
end

#value_added_taxObject

Returns the value of attribute value_added_tax.



4
5
6
# File 'lib/xsys/model/product.rb', line 4

def value_added_tax
  @value_added_tax
end

Instance Method Details

#stock_in(shop_code) ⇒ Object



22
23
24
# File 'lib/xsys/model/product.rb', line 22

def stock_in(shop_code)
  stocks.find { |s| s.shop_code.to_sym == shop_code.to_sym }.try(:quantity)
end