Class: ActiveCart::Items::MemoryItem

Inherits:
Object
  • Object
show all
Includes:
ActiveCart::Item
Defined in:
lib/active_cart/items/memory_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ActiveCart::Item

#quantity, #quantity=

Constructor Details

#initialize(id, name, price) ⇒ MemoryItem

Returns a new instance of MemoryItem



11
12
13
14
15
# File 'lib/active_cart/items/memory_item.rb', line 11

def initialize(id, name, price)
  @id = id
  @name = name
  @price = price
end

Instance Attribute Details

#idObject

Returns the value of attribute id



4
5
6
# File 'lib/active_cart/items/memory_item.rb', line 4

def id
  @id
end

#nameObject

Returns the value of attribute name



4
5
6
# File 'lib/active_cart/items/memory_item.rb', line 4

def name
  @name
end

#priceObject

Returns the value of attribute price



4
5
6
# File 'lib/active_cart/items/memory_item.rb', line 4

def price
  @price
end

Instance Method Details

#==(item) ⇒ Object



7
8
9
# File 'lib/active_cart/items/memory_item.rb', line 7

def ==(item)
  self.id == item.id
end