Class: Dugway::Item

Inherits:
Struct
  • Object
show all
Defined in:
lib/dugway/cart.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



120
121
122
# File 'lib/dugway/cart.rb', line 120

def id
  @id
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



120
121
122
# File 'lib/dugway/cart.rb', line 120

def name
  @name
end

#optionObject

Returns the value of attribute option

Returns:

  • (Object)

    the current value of option



120
121
122
# File 'lib/dugway/cart.rb', line 120

def option
  @option
end

#productObject

Returns the value of attribute product

Returns:

  • (Object)

    the current value of product



120
121
122
# File 'lib/dugway/cart.rb', line 120

def product
  @product
end

#quantityObject

Returns the value of attribute quantity

Returns:

  • (Object)

    the current value of quantity



120
121
122
# File 'lib/dugway/cart.rb', line 120

def quantity
  @quantity
end

#unit_priceObject

Returns the value of attribute unit_price

Returns:

  • (Object)

    the current value of unit_price



120
121
122
# File 'lib/dugway/cart.rb', line 120

def unit_price
  @unit_price
end

Instance Method Details

#as_json(options = nil) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/dugway/cart.rb', line 125

def as_json(options=nil)
  {
    :id => id,
    :name => name,
    :price => price,
    :unit_price => unit_price,
    :shipping => 0.0,
    :tax => 0.0,
    :total => price,
    :quantity => quantity,
    :product => product['permalink'],
    :option => option['id']
  }
end

#priceObject



121
122
123
# File 'lib/dugway/cart.rb', line 121

def price
  unit_price * quantity
end