Class: LaterDude::Calendar
- Inherits:
-
Object
- Object
- LaterDude::Calendar
- Includes:
- ActionView::Helpers::CaptureHelper, ActionView::Helpers::TagHelper, ActionView::Helpers::UrlHelper
- Defined in:
- lib/later_dude/calendar.rb
Overview
TODO: Maybe make output prettier?
Instance Attribute Summary collapse
-
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(year, month, options = {}, &block) ⇒ Calendar
constructor
A new instance of Calendar.
- #to_html ⇒ Object
Constructor Details
#initialize(year, month, options = {}, &block) ⇒ Calendar
Returns a new instance of Calendar.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/later_dude/calendar.rb', line 10 def initialize(year, month, ={}, &block) @year, @month = year, month = .symbolize_keys.reverse_merge(self.class.) # next_month and previous_month take precedence over next_and_previous_month [:next_month] ||= [:next_and_previous_month] [:previous_month] ||= [:next_and_previous_month] @days = Date.civil(@year, @month, 1)..Date.civil(@year, @month, -1) @block = block end |
Instance Attribute Details
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
8 9 10 |
# File 'lib/later_dude/calendar.rb', line 8 def output_buffer @output_buffer end |
Class Method Details
.default_calendar_options ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/later_dude/calendar.rb', line 178 def { :calendar_class => "calendar", :first_day_of_week => I18n.translate(:'date.first_day_of_week', :default => "0").to_i, :hide_day_names => false, :hide_month_name => false, :use_full_day_names => false, :current_month => I18n.translate(:'date.formats.calendar_header', :default => "%B"), :next_month => false, :previous_month => false, :next_and_previous_month => false, :yield_surrounding_days => false } end |
.weekend?(day) ⇒ Boolean
174 175 176 |
# File 'lib/later_dude/calendar.rb', line 174 def weekend?(day) [0,6].include?(day.wday) # 0 = Sunday, 6 = Saturday end |
Instance Method Details
#to_html ⇒ Object
22 23 24 25 26 |
# File 'lib/later_dude/calendar.rb', line 22 def to_html content_tag(:table, :class => "#{@options[:calendar_class]}") do content_tag(:thead, "#{show_month_names}#{show_day_names}".html_safe) + content_tag(:tbody, show_days) end end |