Sha256: aa171f05fc881c418eaa9b90eee3886b0b33c2c186f6e73d39e0417c37734038

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

require "hiccup"
require "active_model/validations"


module Hiccup
  class Schedule
    extend Hiccup
    include ActiveModel::Validations
    
    
    hiccup :enumerable,
           :validatable,
           :humanizable,
           :inferable,
           :serializable => [:ical]
    
    
    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
    
    
    attr_accessor :kind, :start_date, :ends, :end_date, :skip, :weekly_pattern, :monthly_pattern
    
    
    def to_hash
      {
        :kind => kind,
        :start_date => start_date,
        :ends => ends,
        :end_date => end_date,
        :weekly_pattern => weekly_pattern,
        :monthly_pattern => monthly_pattern
      }
    end
    
    
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hiccup-0.5.3 lib/hiccup/schedule.rb
hiccup-0.5.2 lib/hiccup/schedule.rb
hiccup-0.5.1 lib/hiccup/schedule.rb
hiccup-0.5.0 lib/hiccup/schedule.rb
hiccup-0.4.5 lib/hiccup/schedule.rb
hiccup-0.4.4 lib/hiccup/schedule.rb