Class: App42::Shopping::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/shopping/Cart.rb,
lib/shopping/Catalogue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(category) ⇒ Item

This is a constructor that takes no parameter



45
46
47
# File 'lib/shopping/Cart.rb', line 45

def initialize(cart)
  cart.itemList.push(self)
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



51
52
53
# File 'lib/shopping/Catalogue.rb', line 51

def description
  @description
end

#imageObject

Returns the value of attribute image.



32
33
34
# File 'lib/shopping/Cart.rb', line 32

def image
  @image
end

#itemIdObject

Returns the value of attribute itemId.



32
33
34
# File 'lib/shopping/Cart.rb', line 32

def itemId
  @itemId
end

#nameObject

Returns the value of attribute name.



32
33
34
# File 'lib/shopping/Cart.rb', line 32

def name
  @name
end

#priceObject

Returns the value of attribute price.



32
33
34
# File 'lib/shopping/Cart.rb', line 32

def price
  @price
end

#quantityObject

Returns the value of attribute quantity.



32
33
34
# File 'lib/shopping/Cart.rb', line 32

def quantity
  @quantity
end

#tinyUrlObject

Returns the value of attribute tinyUrl.



51
52
53
# File 'lib/shopping/Catalogue.rb', line 51

def tinyUrl
  @tinyUrl
end

#totalAmountObject

Returns the value of attribute totalAmount.



32
33
34
# File 'lib/shopping/Cart.rb', line 32

def totalAmount
  @totalAmount
end

#urlObject

Returns the value of attribute url.



51
52
53
# File 'lib/shopping/Catalogue.rb', line 51

def url
  @url
end

Instance Method Details

#to_sObject

Returns the Cart Response in JSON format.

Returns:

  • the response in JSON format.



55
56
57
# File 'lib/shopping/Cart.rb', line 55

def to_s
  return "name : #{@name}" + "itemId : #{@itemId}" + "price : #{@price}" + "quantity : #{@quantity}";
end

#toStringObject

Returns the Cart Response in JSON format.

Returns:

  • the response in JSON format.



74
75
76
# File 'lib/shopping/Catalogue.rb', line 74

def toString
  return "itemId : #{@itemId}" + "name : #{@name}" + "description : #{@description}" + "url : #{@url}" + "price : #{@price}";
end