Class: Nickel::Occurrence
- Inherits:
-
Struct
- Object
- Struct
- Nickel::Occurrence
- Defined in:
- lib/nickel/occurrence.rb
Overview
Some notes about this class, type can take the following values: :single, :daily, :weekly, :daymonthly, :datemonthly,
Instance Attribute Summary collapse
-
#date_of_month ⇒ Object
Returns the value of attribute date_of_month.
-
#day_of_week ⇒ Object
Returns the value of attribute day_of_week.
-
#end_date ⇒ Object
Returns the value of attribute end_date.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#interval ⇒ Object
Returns the value of attribute interval.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#type ⇒ Object
Returns the value of attribute type.
-
#week_of_month ⇒ Object
Returns the value of attribute week_of_month.
Instance Method Summary collapse
- #finalize(cur_date) ⇒ Object
-
#initialize(h) ⇒ Occurrence
constructor
A new instance of Occurrence.
- #inspect ⇒ Object
Constructor Details
#initialize(h) ⇒ Occurrence
Returns a new instance of Occurrence.
6 7 8 |
# File 'lib/nickel/occurrence.rb', line 6 def initialize(h) h.each { |k, v| send("#{k}=", v) } end |
Instance Attribute Details
#date_of_month ⇒ Object
Returns the value of attribute date_of_month
4 5 6 |
# File 'lib/nickel/occurrence.rb', line 4 def date_of_month @date_of_month end |
#day_of_week ⇒ Object
Returns the value of attribute day_of_week
4 5 6 |
# File 'lib/nickel/occurrence.rb', line 4 def day_of_week @day_of_week end |
#end_date ⇒ Object
Returns the value of attribute end_date
4 5 6 |
# File 'lib/nickel/occurrence.rb', line 4 def end_date @end_date end |
#end_time ⇒ Object
Returns the value of attribute end_time
4 5 6 |
# File 'lib/nickel/occurrence.rb', line 4 def end_time @end_time end |
#interval ⇒ Object
Returns the value of attribute interval
4 5 6 |
# File 'lib/nickel/occurrence.rb', line 4 def interval @interval end |
#start_date ⇒ Object
Returns the value of attribute start_date
4 5 6 |
# File 'lib/nickel/occurrence.rb', line 4 def start_date @start_date end |
#start_time ⇒ Object
Returns the value of attribute start_time
4 5 6 |
# File 'lib/nickel/occurrence.rb', line 4 def start_time @start_time end |
#type ⇒ Object
Returns the value of attribute type
4 5 6 |
# File 'lib/nickel/occurrence.rb', line 4 def type @type end |
#week_of_month ⇒ Object
Returns the value of attribute week_of_month
4 5 6 |
# File 'lib/nickel/occurrence.rb', line 4 def week_of_month @week_of_month end |
Instance Method Details
#finalize(cur_date) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/nickel/occurrence.rb', line 14 def finalize(cur_date) cur_date = start_date unless start_date.nil? case type when :daily then finalize_daily(cur_date) when :weekly then finalize_weekly(cur_date) when :datemonthly then finalize_datemonthly(cur_date) when :daymonthly then finalize_daymonthly(cur_date) end end |
#inspect ⇒ Object
10 11 12 |
# File 'lib/nickel/occurrence.rb', line 10 def inspect '#<Occurrence ' + members.select { |m| self[m] }.map { |m| %(#{m}: #{self[m]}) }.join(', ') + '>' end |