Class: TerminalCalendar::Month::CalendarDay
- Inherits:
-
Object
- Object
- TerminalCalendar::Month::CalendarDay
- Defined in:
- lib/terminal_calendar/month/calendar_day.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#date ⇒ Date
readonly
The date for this calendar day.
-
#pastel ⇒ Pastel
readonly
The pastel object to use for decorating text.
Instance Method Summary collapse
-
#day ⇒ Integer
Returns the day of the date.
-
#initialize(date, pastel = Pastel.new) ⇒ CalendarDay
constructor
A new instance of CalendarDay.
-
#null? ⇒ false
Returns whether the object is null or not.
-
#render ⇒ String
(also: #to_s)
Renders the day as a string.
-
#today? ⇒ Boolean
Determines if the given date is today.
Constructor Details
#initialize(date, pastel = Pastel.new) ⇒ CalendarDay
Returns a new instance of CalendarDay.
13 14 15 16 |
# File 'lib/terminal_calendar/month/calendar_day.rb', line 13 def initialize(date, pastel=Pastel.new) @date = date @pastel = pastel end |
Instance Attribute Details
#date ⇒ Date (readonly)
Returns The date for this calendar day.
9 10 11 |
# File 'lib/terminal_calendar/month/calendar_day.rb', line 9 def date @date end |
#pastel ⇒ Pastel (readonly)
Returns The pastel object to use for decorating text.
6 7 8 |
# File 'lib/terminal_calendar/month/calendar_day.rb', line 6 def pastel @pastel end |
Instance Method Details
#day ⇒ Integer
Returns the day of the date.
46 47 48 |
# File 'lib/terminal_calendar/month/calendar_day.rb', line 46 def day date.day end |
#null? ⇒ false
Returns whether the object is null or not.
39 40 41 |
# File 'lib/terminal_calendar/month/calendar_day.rb', line 39 def null? false end |
#render ⇒ String Also known as: to_s
Renders the day as a string.
20 21 22 23 24 25 |
# File 'lib/terminal_calendar/month/calendar_day.rb', line 20 def render as_string = day.to_s as_string = " #{as_string}" if as_string.length == 1 as_string = pastel.red(as_string) if today? as_string end |
#today? ⇒ Boolean
Determines if the given date is today.
32 33 34 |
# File 'lib/terminal_calendar/month/calendar_day.rb', line 32 def today? date == Date.today end |