Module: Timespan::Printer

Defined in:
lib/timespan/printer.rb

Instance Method Summary collapse

Instance Method Details



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


34
35
36
# File 'lib/timespan/printer.rb', line 34

def print_duration
	print :duration
end


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

Raises:

  • (ArgumentError)


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_strObject



26
27
28
# File 'lib/timespan/printer.rb', line 26

def to_str
	to_s
end