Module: Timespan::Printer
- Defined in:
- lib/timespan/printer.rb
Instance Method Summary collapse
- #print_dates ⇒ Object
- #print_duration ⇒ Object
- #print_full ⇒ Object
-
#to_s(mode = :full) ⇒ Object
%th => total hours %tm => total minutes %ts => total seconds.
- #to_str ⇒ Object
Instance Method Details
#print_dates ⇒ Object
30 31 32 |
# File 'lib/timespan/printer.rb', line 30 def print_dates "#{i18n_t 'from'} #{print :start_time} #{i18n_t 'to'} #{print :end_time}" end |
#print_duration ⇒ Object
34 35 36 |
# File 'lib/timespan/printer.rb', line 34 def print_duration print :duration end |
#print_full ⇒ Object
38 39 40 |
# File 'lib/timespan/printer.rb', line 38 def print_full [print_dates, i18n_t('lasting'), print_duration].join(' ') end |
#to_s(mode = :full) ⇒ Object
%th => total hours %tm => total minutes %ts => total seconds
20 21 22 23 24 |
# File 'lib/timespan/printer.rb', line 20 def to_s mode = :full meth = "print_#{mode}" raise ArgumentError, "Print mode not supported, was: #{mode}" unless respond_to?(meth) send(meth) end |
#to_str ⇒ Object
26 27 28 |
# File 'lib/timespan/printer.rb', line 26 def to_str to_s end |