class Carender::Core
Attributes
collection[R]
column[R]
view_context[R]
Public Class Methods
new(view_context, options)
click to toggle source
# File lib/carender/core.rb, line 3 def initialize(view_context, options) @view_context = view_context @collection = options[:collection] || [] @column = options[:column] end
Public Instance Methods
render(&block)
click to toggle source
# File lib/carender/core.rb, line 9 def render(&block) calendar = Carender::Calendar.new(year, month) calendar.render(view_context, grouped_collection, &block).html_safe end
Private Instance Methods
grouped_collection()
click to toggle source
# File lib/carender/core.rb, line 26 def grouped_collection Hash.new([]).tap do |hash| collection.each do |c| date = c.send(column).to_date hash[date] = [] if hash[date].empty? hash[date] << c end end end
month()
click to toggle source
# File lib/carender/core.rb, line 22 def month view_context.params[:month].to_i end
year()
click to toggle source
# File lib/carender/core.rb, line 18 def year view_context.params[:year].to_i end