Last active
June 2, 2016 11:06
-
-
Save yukas/5ae3cdeeece1ff7328c7cfecf3f7969c to your computer and use it in GitHub Desktop.
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
class OrderCalulator | |
attr_reader :order | |
attr_reader :total, :fee | |
def initialize(order) | |
@order = order | |
end | |
def calculate | |
@total = calculate_total | |
@fee = calculate_fee | |
end | |
private | |
def calculate_total | |
order.items.sum(&:price) | |
end | |
def calculate_fee | |
total * 0.01 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment