class RRSchedule::Rule
Attributes
gt[RW]
ps[RW]
wday[RW]
Public Class Methods
new(params)
click to toggle source
# File lib/rrschedule.rb, line 352 def initialize(params) self.wday = params[:wday] self.gt = params[:gt] self.ps = params[:ps] end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/rrschedule.rb, line 380 def <=>(other) self.wday == other.wday ? DateTime.parse(self.gt.first.to_s) <=> DateTime.parse(other.gt.first.to_s) : self.wday <=> other.wday end
gt=(gt)
click to toggle source
Array of game times where games are played. Must be valid DateTime objects in the string form
# File lib/rrschedule.rb, line 369 def gt=(gt) @gt = Array(gt).empty? ? ["7:00 PM"] : Array(gt) @gt.collect! do |gt| begin DateTime.parse(gt) rescue raise "game times must be valid time representations in the string form (e.g. 3:00 PM, 11:00 AM, 18:20, etc)" end end end
ps=(ps)
click to toggle source
Array of available playing surfaces. You can pass it any kind of object
# File lib/rrschedule.rb, line 364 def ps=(ps) @ps = Array(ps).empty? ? ["Field #1", "Field #2"] : Array(ps) end
wday=(wday)
click to toggle source
# File lib/rrschedule.rb, line 358 def wday=(wday) @wday = wday ? wday : 1 raise "Rule#wday must be between 0 and 6" unless (0..6).include?(@wday) end