Class: DailyLog::Day
- Inherits:
-
Object
- Object
- DailyLog::Day
- Defined in:
- lib/daily_log/day.rb
Overview
Represents one calendar Day
Constant Summary collapse
- DATE_FORMAT =
Format for dates when printed as stringss
"%Y-%m-%d"
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
The Date object for this Day.
Instance Method Summary collapse
-
#initialize(date) ⇒ Day
constructor
Create a new day.
-
#to_s ⇒ Object
Print the date as a formatted string.
-
#today? ⇒ Boolean
Is this Day today’s calendar Date?.
Constructor Details
#initialize(date) ⇒ Day
Create a new day
date - A valid Date object
20 21 22 |
# File 'lib/daily_log/day.rb', line 20 def initialize(date) @date = date end |
Instance Attribute Details
#date ⇒ Object (readonly)
The Date object for this Day
14 15 16 |
# File 'lib/daily_log/day.rb', line 14 def date @date end |
Instance Method Details
#to_s ⇒ Object
Print the date as a formatted string
Returns String
34 35 36 |
# File 'lib/daily_log/day.rb', line 34 def to_s date.strftime(DATE_FORMAT) end |
#today? ⇒ Boolean
Is this Day today’s calendar Date?
Returns Boolean
27 28 29 |
# File 'lib/daily_log/day.rb', line 27 def today? @date == Date.today end |