Class: Calendario::Renderers::YearRenderer

Inherits:
IntervalRenderer show all
Defined in:
lib/calendario/renderers/year_renderer.rb

Overview

Renders a year, line by line, in a table of 3 columns by 4 rows

Constant Summary collapse

NUMBER_OF_MONTH_COLUMNS =

Number of month columns to display

Returns:

  • (Integer)
3

Constants inherited from IntervalRenderer

IntervalRenderer::EMPTY_DAY_SPACES

Instance Method Summary collapse

Methods inherited from IntervalRenderer

#initialize

Constructor Details

This class inherits a constructor from Calendario::Renderers::IntervalRenderer

Instance Method Details

#render(year, &block) ⇒ RenderedYear

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 year, line by line, in a table of 3 columns by 4 rows

Parameters:

  • year (Year)

    The year to be rendered.

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/calendario/renderers/year_renderer.rb', line 19

def render(year, &block)
  month_renderer.filter = block if block_given?

  lines = [center_year_number(year)]
  rendered_months = render_months(year.months)

  rendered_months.each_slice(NUMBER_OF_MONTH_COLUMNS) do |months|
    0.upto(7) { |month_line| lines << take_row(month_line, months) }
    lines.push('') # Separate rows of months
  end

  RenderedYear.new(lines)
end