Class: Teems::Formatters::CalendarFormatter

Inherits:
Object
  • Object
show all
Includes:
CalendarAttendeeFormatter, CalendarDetailFormatter
Defined in:
lib/teems/formatters/calendar_formatter.rb

Overview

Formats calendar events for terminal display

Constant Summary collapse

RSVP_COUNTS =
%i[accepted declined tentative pending].freeze

Constants included from CalendarAttendeeFormatter

Teems::Formatters::CalendarAttendeeFormatter::RESPONSE_LABELS, Teems::Formatters::CalendarAttendeeFormatter::RESPONSE_SYMBOLS

Instance Method Summary collapse

Constructor Details

#initialize(output:) ⇒ CalendarFormatter

Returns a new instance of CalendarFormatter.



156
157
158
# File 'lib/teems/formatters/calendar_formatter.rb', line 156

def initialize(output:)
  @output = output
end

Instance Method Details

#format_event_detail(event) ⇒ Object

Detailed view of a single event



173
174
175
# File 'lib/teems/formatters/calendar_formatter.rb', line 173

def format_event_detail(event)
  [*(event), '', *detail_body_section(event), *format_attendee_sections(event)].join("\n")
end

#format_event_list_compact(events) ⇒ Object

Compact agenda listing



161
162
163
# File 'lib/teems/formatters/calendar_formatter.rb', line 161

def format_event_list_compact(events)
  events.each_with_index.map { |event, index| build_list_item_line(event, index + 1) }.join("\n")
end

#format_event_list_verbose(events) ⇒ Object

Verbose agenda listing with organizer and RSVP summaries



166
167
168
169
170
# File 'lib/teems/formatters/calendar_formatter.rb', line 166

def format_event_list_verbose(events)
  events.each_with_index.flat_map do |event, index|
    [build_list_item_line(event, index + 1) + list_item_verbose_suffix(event), '']
  end.join("\n")
end