Module TimeDSL
In: merb-helpers/lib/merb-helpers/time_dsl.rb

Provides a a simple way of calling time units and to see the elapsed time between 2 moments

Examples

  142.minutes => returns a value in seconds
  7.days => returns a value in seconds
  1.week => returns a value in seconds
  2.weeks.ago => returns a date
  1.year.since(time) => returns a date
  5.months.since(2.weeks.from_now) => returns a date

Methods

ago   day   days   from_now   hour   hours   minute   minutes   month   months   second   seconds   since   until   week   weeks   year   years  

Public Instance methods

Reads best without arguments: 10.minutes.ago

[Source]

    # File merb-helpers/lib/merb-helpers/time_dsl.rb, line 47
47:   def ago(time = ::Time.now)
48:     time - self
49:   end

[Source]

    # File merb-helpers/lib/merb-helpers/time_dsl.rb, line 26
26:   def day
27:     self * 86400
28:   end
days()

Alias for day

from_now(time = ::Time.now)

Alias for since

[Source]

    # File merb-helpers/lib/merb-helpers/time_dsl.rb, line 21
21:   def hour
22:     self * 3600
23:   end
hours()

Alias for hour

[Source]

    # File merb-helpers/lib/merb-helpers/time_dsl.rb, line 16
16:   def minute
17:     self * 60
18:   end
minutes()

Alias for minute

[Source]

    # File merb-helpers/lib/merb-helpers/time_dsl.rb, line 36
36:   def month
37:     self * 2592000
38:   end
months()

Alias for month

[Source]

    # File merb-helpers/lib/merb-helpers/time_dsl.rb, line 11
11:   def second
12:     self * 1
13:   end
seconds()

Alias for second

Reads best with argument: 10.minutes.since(time)

[Source]

    # File merb-helpers/lib/merb-helpers/time_dsl.rb, line 53
53:   def since(time = ::Time.now)
54:     time + self
55:   end
until(time = ::Time.now)

Alias for ago

[Source]

    # File merb-helpers/lib/merb-helpers/time_dsl.rb, line 31
31:   def week
32:     self * 604800
33:   end
weeks()

Alias for week

[Source]

    # File merb-helpers/lib/merb-helpers/time_dsl.rb, line 41
41:   def year
42:     self * 31471200
43:   end
years()

Alias for year

[Validate]