Class: Time

Inherits:
Object show all
Defined in:
lib/model.rb,
lib/lowline.rb

Instance Method Summary collapse

Instance Method Details

#agoObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/lowline.rb', line 34

def ago
  diff = (Time.now - self).to_i.abs
  if diff < 60
    "second".pluralize diff
  elsif diff < 60*60*3
    "minute".pluralize(diff / 60)
  elsif diff < 60*60*24*3
    "hour".pluralize(diff / (60*60))
  elsif diff < 60*60*24*7*2
    "day".pluralize(diff / (60*60*24))
  elsif diff < 60*60*24*7*8
    "week".pluralize(diff / (60*60*24*7))
  elsif diff < 60*60*24*7*52
    "month".pluralize(diff / (60*60*24*7*4))
  else
    "year".pluralize(diff / (60*60*24*7*52))
  end
end

#old_to_yamlObject



7
# File 'lib/model.rb', line 7

alias :old_to_yaml :to_yaml

#prettyObject



32
# File 'lib/lowline.rb', line 32

def pretty; strftime "%c" end

#pretty_dateObject



33
# File 'lib/lowline.rb', line 33

def pretty_date; strftime "%Y-%m-%d" end

#to_yaml(opts = {}) ⇒ Object



8
9
10
# File 'lib/model.rb', line 8

def to_yaml(opts = {})
  self.utc.old_to_yaml(opts)
end