Skip to content

Instantly share code, notes, and snippets.

@matcouto
Last active August 29, 2015 13:57
Show Gist options
  • Save matcouto/173c7967dd722a01cbca to your computer and use it in GitHub Desktop.
Save matcouto/173c7967dd722a01cbca to your computer and use it in GitHub Desktop.
Cant access property product inside ItemCart
@item_cart = ItemCart.new
input.create_list_of_items.each do |item|
@item_cart.quantity = item[0]
@item_cart.product = Product.new("sfdsfds", "fdfds")
@category = Category.new(return_category_name(@item_cart.product.name))
@item_cart.product.category = @category
@item_cart.price = item[2]
end
####################################
class Product
attr_accessor :category
def initialize(name, type)
@name = name
@type = type
end
end
class Category
def initialize(name)
@name = name
end
end
class ItemCart
attr_accessor :quantity, :product, :price
def initialize
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment