Module: Hublot
- Defined in:
- lib/hublot.rb,
lib/hublot/rails.rb,
lib/hublot/pretty.rb,
lib/hublot/version.rb
Defined Under Namespace
Classes: Rails
Constant Summary collapse
- VERSION =
"0.0.5"
Instance Method Summary collapse
-
#pretty(clock = Time.now) ⇒ Object
Clock argument for testing; defaults to Time.
Instance Method Details
#pretty(clock = Time.now) ⇒ Object
Clock argument for testing; defaults to Time
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hublot/pretty.rb', line 4 def pretty(clock=Time.now) @expired = (clock-self).to_i @today = clock.strftime('%A') @created = self.to_time.strftime('%A') # Require Rails date; test in irb Date::daynames @days = { "Monday" => 1, "Tuesday" => 2, "Wednesday" => 3, "Thursday" => 4, "Friday" => 5, "Saturday" => 6, "Sunday" => 7 } return just_now if just_now? return a_second_ago if a_second_ago? return seconds_ago if seconds_ago? return a_minute_ago if a_minute_ago? return minutes_ago if minutes_ago? return an_hour_ago if an_hour_ago? return today if is_today? return yesterday if is_yesterday? return this_week if this_week? return last_week if last_week? return datetimefiesta end |