Skip to content

Instantly share code, notes, and snippets.

@yukas
Last active June 2, 2016 11:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yukas/5ae3cdeeece1ff7328c7cfecf3f7969c to your computer and use it in GitHub Desktop.
Save yukas/5ae3cdeeece1ff7328c7cfecf3f7969c to your computer and use it in GitHub Desktop.
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