Module: Ago::Numbers

Included in:
Bignum, Fixnum, Float
Defined in:
lib/numbers.rb

Instance Method Summary collapse

Instance Method Details

#agoObject



5
6
7
# File 'lib/numbers.rb', line 5

def ago
  return Time.now - self
end

#dayObject



50
51
52
# File 'lib/numbers.rb', line 50

def day
  days
end

#daysObject



46
47
48
# File 'lib/numbers.rb', line 46

def days
  self * Ago::Units[:day][:basic]
end

#from_nowObject



9
10
11
# File 'lib/numbers.rb', line 9

def from_now
  return Time.now + self
end

#hourObject



58
59
60
# File 'lib/numbers.rb', line 58

def hour
  hours
end

#hoursObject



54
55
56
# File 'lib/numbers.rb', line 54

def hours
  self * Ago::Units[:hour][:basic]
end

#minuteObject



66
67
68
# File 'lib/numbers.rb', line 66

def minute
  minutes
end

#minutesObject



62
63
64
# File 'lib/numbers.rb', line 62

def minutes
  self * Ago::Units[:minute][:basic]
end

#month(opts = {}) ⇒ Object



31
32
33
# File 'lib/numbers.rb', line 31

def month(opts={})
  months(opts)
end

#months(opts = {}) ⇒ Object



24
25
26
27
28
29
# File 'lib/numbers.rb', line 24

def months(opts={})
  calendar = opts[:calendar] ? opts[:calendar] : :basic
  Ago.calendar_check(calendar)
 
  self * Ago::Units[:month][calendar]
end

#secondObject



74
75
76
# File 'lib/numbers.rb', line 74

def second
  seconds
end

#secondsObject



70
71
72
# File 'lib/numbers.rb', line 70

def seconds
  self * Ago::Units[:second][:basic]
end

#week(opts = {}) ⇒ Object



42
43
44
# File 'lib/numbers.rb', line 42

def week(opts={})
  weeks(opts)
end

#weeks(opts = {}) ⇒ Object



35
36
37
38
39
40
# File 'lib/numbers.rb', line 35

def weeks(opts={})
  calendar = opts[:calendar] ? opts[:calendar] : :basic
  Ago.calendar_check(calendar)
  
  self * Ago::Units[:week][calendar]
end

#year(opts = {}) ⇒ Object



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

def year(opts={})
  years(opts)
end

#years(opts = {}) ⇒ Object



13
14
15
16
17
18
# File 'lib/numbers.rb', line 13

def years(opts={})
  calendar = opts[:calendar] ? opts[:calendar] : :basic
  Ago.calendar_check(calendar)
  
  self * Ago::Units[:year][calendar]
end