Class: Time
Instance Method Summary collapse
- #ago ⇒ Object
- #old_to_yaml ⇒ Object
- #pretty ⇒ Object
- #pretty_date ⇒ Object
- #to_yaml(opts = {}) ⇒ Object
Instance Method Details
#ago ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ditzstr/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_yaml ⇒ Object
7 |
# File 'lib/ditzstr/model.rb', line 7 alias :old_to_yaml :to_yaml |
#pretty ⇒ Object
32 |
# File 'lib/ditzstr/lowline.rb', line 32 def pretty; strftime "%c" end |
#pretty_date ⇒ Object
33 |
# File 'lib/ditzstr/lowline.rb', line 33 def pretty_date; strftime "%Y-%m-%d" end |
#to_yaml(opts = {}) ⇒ Object
8 9 10 |
# File 'lib/ditzstr/model.rb', line 8 def to_yaml(opts = {}) self.utc.old_to_yaml(opts) end |