class ProdutItem
attr_reader :item, :price_unit, :qtde
def initialize(item, price_unit, qtde)
@item = item
@price_unit = price_unit
@qtde = qtde
end
def calc_qtde
(price_unit * qtde)
end
end
prod = ProdutItem.new("A", 0.50, 3)
puts prod.calc_qtde
class CalcDiscount
attr_reader :discount
def initialize(discount)
@discount = discount
end
def calc_desc
(price_unit * qtde) - discount
end
end
desc = CalcDiscount.new(0.20)
puts desc.calc_desc
When I execute this my code above returns the following error msg:
teste_04.rb: 29: in
calc_desc': undefined local variable or method
price_unit 'for # (NameError) from teste_04.rb: 34: in ''
Eu nao consigo identificar o erro. Alguem poderia me ajudar?