Class: Date

Inherits:
Object
  • Object
show all
Defined in:
lib/kin/core_ext/date.rb

Instance Method Summary collapse

Instance Method Details

#fuzzyString

Fuzzy-formats the date. If the date is yesterday, today or tomorrow, a simpler date will be given.

Examples:

Today.

Date.today.fuzzy # => "Today"

Some time ago.

(Date.today - 7).fuzzy # => "Wednesday 29th July"

Returns:



14
15
16
17
18
19
20
21
22
23
# File 'lib/kin/core_ext/date.rb', line 14

def fuzzy
  today = Date.today

  case self
    when today     then 'Today'
    when today - 1 then 'Yesterday'
    when today + 1 then 'Tomorrow'
    else                 to_ordinalized_s(:date_only)
  end
end