-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
89 additions
and
89 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
class TotalCostCalculator | ||
attr_reader :annual_cost, | ||
:biannual_cost, | ||
:quarterly_cost, | ||
:monthly_cost, | ||
:bi_weekly_cost, | ||
:weekly_cost, | ||
:daily_cost | ||
|
||
def initialize(cost:) | ||
@annual_cost = cost | ||
@biannual_cost = calculate_biannual_cost | ||
@quarterly_cost = calculate_quarterly_cost | ||
@monthly_cost = calculate_monthly_cost | ||
@bi_weekly_cost = calculate_bi_weekly_cost | ||
@weekly_cost = calculate_weekly_cost | ||
@daily_cost = calculate_daily_cost | ||
end | ||
|
||
def calculate_biannual_cost | ||
@annual_cost / 2 | ||
end | ||
|
||
def calculate_quarterly_cost | ||
@annual_cost / 4 | ||
end | ||
|
||
def calculate_monthly_cost | ||
@annual_cost / 12 | ||
end | ||
|
||
def calculate_bi_weekly_cost | ||
@annual_cost / 26 | ||
end | ||
|
||
def calculate_weekly_cost | ||
@annual_cost / 52 | ||
end | ||
|
||
def calculate_daily_cost | ||
@annual_cost / 365 | ||
end | ||
end |
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
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
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
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
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
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
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
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
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
Oops, something went wrong.