Class: Fixnum

Inherits:
Object
  • Object
show all
Defined in:
lib/time_win/fixnum_ext.rb

Instance Method Summary collapse

Instance Method Details

#daysObject



32
33
34
# File 'lib/time_win/fixnum_ext.rb', line 32

def days
  self*86400
end

#days_agoObject



12
13
14
# File 'lib/time_win/fixnum_ext.rb', line 12

def days_ago
  (self * 86400).seconds_ago
end

#hoursObject



28
29
30
# File 'lib/time_win/fixnum_ext.rb', line 28

def hours
  self*3600
end

#hours_agoObject



16
17
18
# File 'lib/time_win/fixnum_ext.rb', line 16

def hours_ago
  (self * 3600).seconds_ago
end

#minutesObject



24
25
26
# File 'lib/time_win/fixnum_ext.rb', line 24

def minutes
  self*60
end

#minutes_agoObject



20
21
22
# File 'lib/time_win/fixnum_ext.rb', line 20

def minutes_ago
  (self * 60).seconds_ago
end

#months_agoObject



7
8
9
10
# File 'lib/time_win/fixnum_ext.rb', line 7

def months_ago
  t = Time.now
  (self * Date.days_in_month(t.year, t.month) * 86400).seconds_ago
end

#seconds_agoObject



40
41
42
# File 'lib/time_win/fixnum_ext.rb', line 40

def seconds_ago
  Time.now - self
end

#weeksObject



36
37
38
# File 'lib/time_win/fixnum_ext.rb', line 36

def weeks
  7*days
end

#years_agoObject



3
4
5
# File 'lib/time_win/fixnum_ext.rb', line 3

def years_ago
  (self * (Date.leap?(Time.now.year) ? 366 : 265) * 86400).seconds_ago
end