Class: TerminalCalendar::Selection::MonthPage
- Inherits:
-
Object
- Object
- TerminalCalendar::Selection::MonthPage
- Defined in:
- lib/terminal_calendar/selection/month_page.rb
Constant Summary collapse
- WEEK_ROW =
%w(Su Mo Tu We Th Fr Sa).freeze
Instance Attribute Summary collapse
-
#month ⇒ Object
readonly
Returns the value of attribute month.
-
#selection_grid ⇒ Object
readonly
Returns the value of attribute selection_grid.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(month, pastel = Pastel.new) ⇒ MonthPage
constructor
A new instance of MonthPage.
- #line_count ⇒ Object
- #redraw_lines ⇒ Object
-
#render ⇒ String
Renders the calendar as a string.
- #selection_grid_lines ⇒ Object
Constructor Details
#initialize(month, pastel = Pastel.new) ⇒ MonthPage
Returns a new instance of MonthPage.
13 14 15 16 17 |
# File 'lib/terminal_calendar/selection/month_page.rb', line 13 def initialize(month, pastel=Pastel.new) @selection_grid = Grid.build_from_objects(month.as_rows) @month = month @pastel = pastel end |
Instance Attribute Details
#month ⇒ Object (readonly)
Returns the value of attribute month.
7 8 9 |
# File 'lib/terminal_calendar/selection/month_page.rb', line 7 def month @month end |
#selection_grid ⇒ Object (readonly)
Returns the value of attribute selection_grid.
7 8 9 |
# File 'lib/terminal_calendar/selection/month_page.rb', line 7 def selection_grid @selection_grid end |
Class Method Details
.build(month) ⇒ Object
9 10 11 |
# File 'lib/terminal_calendar/selection/month_page.rb', line 9 def self.build(month) new(month) end |
Instance Method Details
#line_count ⇒ Object
33 34 35 |
# File 'lib/terminal_calendar/selection/month_page.rb', line 33 def line_count @line_count ||= render_rows.count end |
#redraw_lines ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/terminal_calendar/selection/month_page.rb', line 25 def redraw_lines if selection_grid.redraw_at.nil? || selection_grid.redraw_at.negative? calendar_header(selected: selection_grid&.redraw_at == -1).concat(selection_grid.redraw_lines) else selection_grid.redraw_lines end end |
#render ⇒ String
Renders the calendar as a string.
21 22 23 |
# File 'lib/terminal_calendar/selection/month_page.rb', line 21 def render render_rows.join("\n") end |
#selection_grid_lines ⇒ Object
37 38 39 |
# File 'lib/terminal_calendar/selection/month_page.rb', line 37 def selection_grid_lines selection_grid.render_lines end |