Initial commit

This commit is contained in:
Senad Uka
2020-05-31 22:38:19 +02:00
commit 858fafc3c5
1280 changed files with 65918 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
module DurationHelper
MINUTES_IN_HOUR = 60
SECONDS_IN_MINUTE = 60
def convert_duration(value, from:, to:)
value_in_seconds = case from.to_s
when "seconds" then value
when "minutes" then value * SECONDS_IN_MINUTE
when "hours" then value * SECONDS_IN_MINUTE * MINUTES_IN_HOUR
end
result = case to.to_s
when "seconds" then value_in_seconds
when "minutes" then value_in_seconds / SECONDS_IN_MINUTE
when "hours" then value_in_seconds / SECONDS_IN_MINUTE / MINUTES_IN_HOUR
end
end
end