Class: Pizza
- Inherits:
-
Object
- Object
- Pizza
- Defined in:
- lib/pizza.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
Instance Method Summary collapse
-
#initialize(amount) ⇒ Pizza
constructor
A new instance of Pizza.
- #larges ⇒ Object
- #mediums ⇒ Object
Constructor Details
#initialize(amount) ⇒ Pizza
Returns a new instance of Pizza.
4 5 6 |
# File 'lib/pizza.rb', line 4 def initialize(amount) @amount = amount end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
2 3 4 |
# File 'lib/pizza.rb', line 2 def amount @amount end |
Instance Method Details
#larges ⇒ Object
13 14 15 16 |
# File 'lib/pizza.rb', line 13 def larges amt = ((amount.to_f + 1)/4) (amt.to_s).include?(".25") ? (amt + 1).round : amt.round end |
#mediums ⇒ Object
8 9 10 11 |
# File 'lib/pizza.rb', line 8 def mediums amt = ((amount.to_f + 1)/3) (amt.to_s).include?(".33") ? (amt + 1).round : amt.round end |