Skip to content

Commit

Permalink
* Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
ledestin committed Aug 17, 2014
1 parent 2b5fe19 commit d5a6331
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def to_s

private
def tax_rate
@tax_rates.tax_rate_for_good(name)
@tax_rates.tax_rate_for_good name
end

def unit_tax
TaxCalculator.calc_tax(unit_price, tax_rate)
TaxCalculator.calc_tax unit_price, tax_rate
end

def unit_total
Expand Down
2 changes: 1 addition & 1 deletion lib/numeric_money_format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module NumericMoneyFormat
def to_formatted_s(format = :default)
return super() unless format == :money

sprintf("%.2f", self)
sprintf "%.2f", self
end
end
end
4 changes: 2 additions & 2 deletions lib/receipt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def to_s
<<EOF
#{@goods.join("\n")}
Sales Taxes: #{tax.to_formatted_s(:money)}
Total: #{total.to_formatted_s(:money)}
Sales Taxes: #{tax.to_formatted_s :money}
Total: #{total.to_formatted_s :money}
EOF
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/shopping_cart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ def initialize(items)
end

def receipt
Receipt.new(items)
Receipt.new items
end
end
2 changes: 1 addition & 1 deletion lib/tax_calculator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module TaxCalculator
def self.calc_tax(amount, tax_rate)
tax = amount * tax_rate
round_up_to_nearest_5_cents(tax)
round_up_to_nearest_5_cents tax
end

def self.round_up_to_nearest_5_cents(amount)
Expand Down

0 comments on commit d5a6331

Please sign in to comment.