Class: Portera::Participant::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/portera/participant.rb

Overview

Internal builder for participant availability

Constant Summary collapse

Days =
{ :sunday => 0,
  :monday => 1,
  :tuesday => 2,
  :wednesday => 3,
  :thursday => 4,
  :friday => 5,
  :saturday => 6,
  :sun => 0,
  :mon => 1,
  :tue => 2,
  :wed => 3,
  :thu => 4,
  :fri => 5,
  :sat => 6,
  :su  => 0,
  :m   => 1,
  :tu  => 2,
  :w   => 3,
  :th  => 4,
  :f   => 5,
  :sa  => 6,
  :Sunday => 0,
  :Monday => 1,
  :Tuesday => 2,
  :Wednesday => 3,
  :Thursday => 4,
  :Friday => 5,
  :Saturday => 6,
  :Sun => 0,
  :Mon => 1,
  :Tue => 2,
  :Wed => 3,
  :Thu => 4,
  :Fri => 5,
  :Sat => 6,
  :Su  => 0,
  :M   => 1,
  :Tu  => 2,
  :W   => 3,
  :Th  => 4,
  :F   => 5,
  :Sa  => 6
}

Instance Method Summary collapse

Constructor Details

#initialize(collect, utc_offset = nil) ⇒ Builder

Returns a new instance of Builder.



92
93
94
95
# File 'lib/portera/participant.rb', line 92

def initialize(collect,utc_offset=nil)
  @collect = collect
  @utc_offset = utc_offset || 0
end

Instance Method Details

#any_day(time = {}) ⇒ Object

sugar for ‘on( [], time)`



117
118
119
# File 'lib/portera/participant.rb', line 117

def any_day(time={})
  on( [], time)
end

#on(days, time = {}) ⇒ Object

Example:

on [2,3,5], :from => '9:00am', :to => '9:30am', :utc_offset => '-05:00'

Note that if not specified, timezone is

  1. the offset passed into the constructor, or

  2. UTC, otherwise – _not the process-local timezone_!



103
104
105
106
107
108
109
# File 'lib/portera/participant.rb', line 103

def on(days, time={})
  @collect << Availability.new( Array(days).map {|d| to_weekday(d)}, 
                                time[:from], 
                                time[:to], 
                                time[:utc_offset] || @utc_offset
                              )
end

#weekdays(time = {}) ⇒ Object

sugar for ‘on( [1,2,3,4,5], time)`



112
113
114
# File 'lib/portera/participant.rb', line 112

def weekdays(time={})
  on( [1,2,3,4,5], time)
end