Skip to content

Instantly share code, notes, and snippets.

@komagata
Created June 17, 2013 10:27
Show Gist options
  • Save komagata/5796006 to your computer and use it in GitHub Desktop.
Save komagata/5796006 to your computer and use it in GitHub Desktop.
pv and profit.
#!/usr/bin/env ruby
def growth_rate(prev, current)
(current.to_f / prev.to_f * 100.0 - 100.0)
end
prev_pv = 1518572
current_pv = 1657536
prev_profit = 188154
current_profit = 165979
puts "PV: #{growth_rate(prev_pv, current_pv).round(2)} %"
puts "Profit: #{growth_rate(prev_profit, current_profit).round(2)} %"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment