Module: SimpleCalendar::ViewHelpers

Defined in:
lib/simple_calendar/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#calendar(events, options = {}, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/simple_calendar/view_helpers.rb', line 4

def calendar(events, options={}, &block)
  raise 'SimpleCalendar requires a block to be passed in' unless block_given?

  opts = default_options
  options.reverse_merge! opts
  events       ||= []
  selected_month = Date.new(options[:year], options[:month])
  current_date   = Time.zone.now.to_date
  range          = build_range selected_month, options
  month_array    = range.each_slice(7).to_a

  draw_calendar(selected_month, month_array, current_date, events, options, block)
end