Class: RubyApp::Elements::Calendars::Base::BaseMonth

Inherits:
RubyApp::Element show all
Defined in:
lib/ruby_app/elements/calendars/base/base_month.rb

Direct Known Subclasses

Month

Defined Under Namespace

Classes: ChangedEvent, MovedEvent

Instance Attribute Summary collapse

Attributes inherited from RubyApp::Element

#attributes

Instance Method Summary collapse

Methods inherited from RubyApp::Element

#element_id, get_element

Methods included from Mixins::ConfigurationMixin

#configuration

Methods included from Mixins::TranslateMixin

#localize, #translate

Methods included from Mixins::TemplateMixin

#exclude_parent_template, #exclude_parent_template?, #get_cache, #get_template, #get_templates, #template_name, #template_path

Methods included from Mixins::RenderMixin

#content_for, #render, #rendered?

Constructor Details

#initialize(today = Date.today, display = nil, value = nil) ⇒ BaseMonth

Returns a new instance of BaseMonth.



54
55
56
57
58
59
# File 'lib/ruby_app/elements/calendars/base/base_month.rb', line 54

def initialize(today = Date.today, display = nil, value = nil)
  super()
  @today = today
  @display = display || today
  @value = value || @display
end

Instance Attribute Details

#displayObject

Returns the value of attribute display.



50
51
52
# File 'lib/ruby_app/elements/calendars/base/base_month.rb', line 50

def display
  @display
end

#todayObject

Returns the value of attribute today.



50
51
52
# File 'lib/ruby_app/elements/calendars/base/base_month.rb', line 50

def today
  @today
end

#valueObject

Returns the value of attribute value.



50
51
52
# File 'lib/ruby_app/elements/calendars/base/base_month.rb', line 50

def value
  @value
end

Instance Method Details

#display_first_dateObject



61
62
63
64
# File 'lib/ruby_app/elements/calendars/base/base_month.rb', line 61

def display_first_date
  first_of_month = @display - (@display.day - 1)
  first_of_month - first_of_month.wday
end

#display_last_dateObject



66
67
68
69
70
# File 'lib/ruby_app/elements/calendars/base/base_month.rb', line 66

def display_last_date
  next_month = @display >> 1
  last_of_month = next_month - next_month.day
  last_of_month + (6 - last_of_month.wday)
end