class EventsView
Public Instance Methods
render_events(events)
click to toggle source
# File lib/dbc_today/views/events_view.rb, line 4 def render_events(events) "\nSCHEDULE\n".bold + "#{header_row}\n" + events.map { |event| event_row(event) }.join("\n") + "\n" end
Private Instance Methods
cell(value, width)
click to toggle source
# File lib/dbc_today/views/events_view.rb, line 24 def cell(value, width) string = value .to_s .tr('_', ' ') .ljust(width - 1) + ' ' if string.length > width string[0..width - 5] + '... ' else string end end
columns()
click to toggle source
# File lib/dbc_today/views/events_view.rb, line 13 def columns { phase: 6, week: 6, day: 6, description: 20, start_time: 12, end_time: 12 } end
event_row(event)
click to toggle source
# File lib/dbc_today/views/events_view.rb, line 45 def event_row(event) cells = columns .map { |k, v| cell(event.send(k), v) } string = cells.join if event.all_day? string.blue elsif event.moment? string.red else string end end
header_row()
click to toggle source
# File lib/dbc_today/views/events_view.rb, line 37 def header_row headers = columns .map { |k, v| cell(k, v) } headers.join.underline end