Class: Seconds
Overview
#
Note that this is deliberately defined on the toplevel Object, rather than within the Roebe “namespace”.
This class will convert 27216 into:
27216 seconds are 7 hours, 33 minutes and 36 seconds.
#
Instance Method Summary collapse
-
#convert_the_data ⇒ Object
# === convert_the_data ========================================================================= #.
-
#initialize(i, run_already = true) ⇒ Seconds
constructor
# === initialize ========================================================================= #.
-
#report_our_findings ⇒ Object
(also: #report)
# === report_our_findings ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#run ⇒ Object
# === run ========================================================================= #.
-
#set_n_seconds(i) ⇒ Object
# === set_n_seconds ========================================================================= #.
Constructor Details
Instance Method Details
#convert_the_data ⇒ Object
#
convert_the_data
#
49 50 51 52 53 54 55 |
# File 'lib/roebe/time/seconds.rb', line 49 def convert_the_data @n_minutes = @n_seconds / 60 @n_hours = @n_minutes / 60 @n_remaining_minutes = @n_minutes - (@n_hours * 60) @n_remaining_seconds = @n_seconds - (@n_minutes * 60) end |
#report_our_findings ⇒ Object Also known as: report
#
report_our_findings
#
60 61 62 63 64 65 |
# File 'lib/roebe/time/seconds.rb', line 60 def report_our_findings e @n_seconds.to_s+' seconds are '+ @n_hours.to_s+' hours, '+ @n_remaining_minutes.to_s+' minutes and '+ @n_remaining_seconds.to_s+' seconds.' end |
#reset ⇒ Object
#
reset
#
39 40 41 42 43 44 |
# File 'lib/roebe/time/seconds.rb', line 39 def reset # ======================================================================= # # === @n_seconds # ======================================================================= # @n_seconds = 0 # This is the initial value. end |