Method: TimeInterval#strftime

Defined in:
lib/timeinterval.rb

#strftime(fmt = "%H:%M:%S") ⇒ Object

Formats time interval according to the directives in the given format string.

i = TimeInterval.new(2342) #2342 seconds
i.strftime( "%H" )  => "00"
i.strftime( "%M" )  => "39"
i.strftime( "%S" )  => "02"


69
70
71
72
73
74
75
76
77
78
79
# File 'lib/timeinterval.rb', line 69

def strftime( fmt = "%H:%M:%S" )
  fmt.gsub( /%(.)/ ) do | match |
    case match[1,1]
      when 'H' then sprintf('%02d',@hour)
      when 'M' then sprintf('%02d',@min)
      when 'S' then sprintf('%02d',@sec)
      when '%' then '%'
      else match
    end
  end
end