Class: Hiccup::Schedule

Inherits:
Object
  • Object
show all
Extended by:
Hiccup
Includes:
ActiveModel::Validations
Defined in:
lib/hiccup/schedule.rb

Constant Summary

Constants included from Hiccup

Kinds, VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Hiccup

hiccup

Constructor Details

#initialize(options = {}) ⇒ Schedule

Returns a new instance of Schedule.



18
19
20
21
22
23
24
25
26
# File 'lib/hiccup/schedule.rb', line 18

def initialize(options={})
  @kind             =(options[:kind] || :never).to_sym
  @start_date       =(options[:start_date] || Date.today).to_date
  @ends             = options.key?(:ends) ? options[:ends] : false
  @end_date         = options[:end_date] ? options[:end_date].to_date : nil
  @skip             =(options[:skip] || options[:interval] || 1).to_i
  @weekly_pattern   = options[:weekly_pattern] || []
  @monthly_pattern  = options[:monthly_pattern] || []
end

Instance Attribute Details

#end_dateObject

Returns the value of attribute end_date.



29
30
31
# File 'lib/hiccup/schedule.rb', line 29

def end_date
  @end_date
end

#endsObject

Returns the value of attribute ends.



29
30
31
# File 'lib/hiccup/schedule.rb', line 29

def ends
  @ends
end

#kindObject

Returns the value of attribute kind.



29
30
31
# File 'lib/hiccup/schedule.rb', line 29

def kind
  @kind
end

#monthly_patternObject

Returns the value of attribute monthly_pattern.



29
30
31
# File 'lib/hiccup/schedule.rb', line 29

def monthly_pattern
  @monthly_pattern
end

#skipObject

Returns the value of attribute skip.



29
30
31
# File 'lib/hiccup/schedule.rb', line 29

def skip
  @skip
end

#start_dateObject

Returns the value of attribute start_date.



29
30
31
# File 'lib/hiccup/schedule.rb', line 29

def start_date
  @start_date
end

#weekly_patternObject

Returns the value of attribute weekly_pattern.



29
30
31
# File 'lib/hiccup/schedule.rb', line 29

def weekly_pattern
  @weekly_pattern
end

Instance Method Details

#to_hashObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/hiccup/schedule.rb', line 32

def to_hash
  {
    :kind => kind,
    :start_date => start_date,
    :ends => ends,
    :end_date => end_date,
    :weekly_pattern => weekly_pattern,
    :monthly_pattern => monthly_pattern
  }
end