Class: Calendario::Renderers::IntervalRenderer
- Inherits:
-
Object
- Object
- Calendario::Renderers::IntervalRenderer
- Defined in:
- lib/calendario/renderers/interval_renderer.rb
Overview
Renders a time interval, line by line, in a table
Direct Known Subclasses
Constant Summary collapse
- EMPTY_DAY_SPACES =
The space of an empty day
' '.freeze
Instance Method Summary collapse
-
#initialize(month_renderer = MonthRenderer.new) ⇒ IntervalRenderer
constructor
private
Initializes a interval renderer.
-
#render(interval, columns:, &block) ⇒ RenderedInterval
private
Formats a time interval, line by line, in a table.
Constructor Details
#initialize(month_renderer = MonthRenderer.new) ⇒ IntervalRenderer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes a interval renderer
18 19 20 |
# File 'lib/calendario/renderers/interval_renderer.rb', line 18 def initialize(month_renderer = MonthRenderer.new) @month_renderer = month_renderer end |
Instance Method Details
#render(interval, columns:, &block) ⇒ RenderedInterval
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats a time interval, line by line, in a table
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/calendario/renderers/interval_renderer.rb', line 28 def render(interval, columns:, &block) month_renderer.filter = block if block_given? lines = [] rendered_months = render_months(interval.months) rendered_months.each_slice(columns) do |months| 0.upto(7) { |month_line| lines << take_row(month_line, months) } lines.push('') # Separate rows of months end RenderedInterval.new(lines) end |