From 89d5e4a071a56fd0e7138517c32998e1846c5319 Mon Sep 17 00:00:00 2001 From: Javi R <4920956+rameerez@users.noreply.github.com> Date: Sun, 1 Sep 2024 02:04:49 +0100 Subject: [PATCH] Add syntactic sugar so we can also write `estimated_valuation(multiple: 3)` (h/t @marckohlbrugge) --- README.md | 8 ++++---- lib/profitable.rb | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d4ebaed..8d2fb41 100644 --- a/README.md +++ b/README.md @@ -100,11 +100,11 @@ Profitable.churn(in_the_last: 3.months).to_readable # => "12%" # You can specify the precision of the output number (no decimals by default) Profitable.new_mrr(in_the_last: 24.hours).to_readable(2) # => "$123.45" -# Get the estimated valuation at 5x ARR -Profitable.estimated_valuation(at: "5x").to_readable # => "$500,000" +# Get the estimated valuation at 5x ARR (defaults to 3x if no multiple is specified) +Profitable.estimated_valuation(multiple: 5).to_readable # => "$500,000" -# You can also pass the multiplier as a number, and/or ignore the "at:" keyword altogether -Profitable.estimated_valuation(4.5).to_readable # => "$450,000" +# You can also pass the multiplier as a string. You can also use the `at:` keyword argument (same thing as `multiplier:`) – and/or ignore the `at:` or `multiplier:` named arguments altogether +Profitable.estimated_valuation(at: "4.5x").to_readable # => "$450,000" # Get the time to next MRR milestone Profitable.time_to_next_mrr_milestone.to_readable # => "26 days left to $10,000 MRR" diff --git a/lib/profitable.rb b/lib/profitable.rb index d0b00c8..42d8da0 100644 --- a/lib/profitable.rb +++ b/lib/profitable.rb @@ -46,8 +46,8 @@ def recurring_revenue_percentage(in_the_last: DEFAULT_PERIOD) NumericResult.new(calculate_recurring_revenue_percentage(in_the_last), :percentage) end - def estimated_valuation(multiplier = 3, at: nil) - actual_multiplier = at || multiplier + def estimated_valuation(multiplier = nil, at: nil, multiple: nil) + actual_multiplier = multiplier || at || multiple || 3 NumericResult.new(calculate_estimated_valuation(actual_multiplier)) end