Class: Fixnum

Inherits:
Object show all
Defined in:
lib/kiss/ext/core.rb

Overview

Enables FixNum conversion to time duration values (in seconds).

Instance Method Summary collapse

Instance Method Details

#agoObject

5.minutes.ago = Time.now - 300



354
355
356
# File 'lib/kiss/ext/core.rb', line 354

def ago
  Time.now - self
end

#daysObject

1.days = 24.hours



338
339
340
# File 'lib/kiss/ext/core.rb', line 338

def days
  self * 24.hours
end

#format_thousandsObject

format thousands



359
360
361
# File 'lib/kiss/ext/core.rb', line 359

def format_thousands
  to_s.reverse.gsub(/(\d{3})/, '\1,').sub(/\,(-?)$/, '\1').reverse
end

#hoursObject

1.hours = 60.minutes = 3600 (seconds)



343
344
345
# File 'lib/kiss/ext/core.rb', line 343

def hours
  self * 60.minutes
end

#minutesObject

1.minutes = 60 (seconds) 5.minutes = 300 (seconds)



349
350
351
# File 'lib/kiss/ext/core.rb', line 349

def minutes
  self * 60
end

#monthsObject

Not exact



328
329
330
# File 'lib/kiss/ext/core.rb', line 328

def months
  self * 30.days
end

#weeksObject

2.weeks = 14.days



333
334
335
# File 'lib/kiss/ext/core.rb', line 333

def weeks
  self * 7.days
end

#yearsObject

Not exact



323
324
325
# File 'lib/kiss/ext/core.rb', line 323

def years
  self * 365.days
end