Class: Product

Inherits:
Object
  • Object
show all
Defined in:
lib/machine/product.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, price:) ⇒ Product

Returns a new instance of Product.



6
7
8
9
# File 'lib/machine/product.rb', line 6

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/machine/product.rb', line 4

def name
  @name
end

#priceObject (readonly)

Returns the value of attribute price.



4
5
6
# File 'lib/machine/product.rb', line 4

def price
  @price
end

Instance Method Details

#cash_valueObject



11
12
13
# File 'lib/machine/product.rb', line 11

def cash_value
  Cash.cash_value(price)
end