class Calendario::Calendar

A time period to be rendered

Attributes

year_renderer[R]

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

@api private @return [Calendario::Renderers::YearRenderer]

Public Class Methods

new(year_renderer = Renderers::YearRenderer.new) click to toggle source

Initialize a calendar

@api private @param [Calendario::Renderers::YearRenderer] year_renderer # Formats a year, line by line, in a table of 3 columns by 4 rows

# File lib/calendario/calendar.rb, line 20
def initialize(year_renderer = Renderers::YearRenderer.new)
  @year_renderer = year_renderer
end

Public Instance Methods

render_current_year(&block) click to toggle source

Renders the current year as a string

@api public

@example Rendering the current year

calendar = Calendario::Calendar.new
calendar.render_current_year

@example Rendering a customized version of the current year

calendar = Calendario::Calendar.new
calendar.render_current_year do |date|
  if date.wday == 5 ||  if date.wday == 6
    'WE'
  else
    date.day.to_s.rjust(2)
  end
end

@return [RenderedYear]

# File lib/calendario/calendar.rb, line 44
def render_current_year(&block)
  year = Year.new(Date.today.year)
  year_renderer.render(year, &block)
end