-
-
Save matcouto/173c7967dd722a01cbca to your computer and use it in GitHub Desktop.
Cant access property product inside ItemCart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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