class String
Public Instance Methods
last()
click to toggle source
# File lib/rm_old.rb, line 54 def last self[-1, 1] end
to_duration()
click to toggle source
# File lib/rm_old.rb, line 35 def to_duration s = self.gsub(' ', '').strip unit = s.last ord = s.chomp(unit).to_f second = 1.0 minute = second * 60 hour = minute * 60 day = hour * 24 week = day * 7 return ord * week if unit == 'w' return ord * day if unit == 'd' return ord * hour if unit == 'h' return ord * minute if unit == 'm' return ord * second if unit == 's' raise "could not parse duration #{self}" end