Class: RatatuiRuby::Widgets::Calendar

Inherits:
Object
  • Object
show all
Includes:
CoerceableWidget
Defined in:
lib/ratatui_ruby/widgets/calendar.rb

Overview

Displays a monthly calendar grid.

Dates are complex. Rendering them in a grid requires calculation of leap years, month lengths, and day-of-week offsets. Use this widget to skip the boilerplate.

This widget renders a standard monthly view. It highlights the current date. It structures time.

Use it for date pickers, schedulers, or logs.

Example

Run the interactive demo from the terminal:

ruby examples/widget_calendar/app.rb

Instance Method Summary collapse

Methods included from CoerceableWidget

included

Constructor Details

#initialize(year:, month:, events: {}, default_style: nil, header_style: nil, block: nil, show_weekdays_header: true, show_surrounding: nil, show_month_header: false) ⇒ Calendar

Creates a new Calendar.

year

Integer.

month

Integer.

events

Hash<Date, Style>. Optional.

default_style

Style.

header_style

Style.

block

Block.

show_weekdays_header

Boolean. Whether to show the weekday header.

show_surrounding

Style or nil. Style for surrounding month dates.



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/ratatui_ruby/widgets/calendar.rb', line 73

def initialize(year:, month:, events: {}, default_style: nil, header_style: nil, block: nil, show_weekdays_header: true, show_surrounding: nil, show_month_header: false)
  super(
    year: Integer(year),
    month: Integer(month),
    events:,
    default_style:,
    header_style:,
    block:,
    show_weekdays_header:,
    show_surrounding:,
    show_month_header:
  )
end