class Blackcal::Builder
Builder
provides a DSL for schedule options
Public Class Methods
dsl(&block)
click to toggle source
Enables a DSL for building schedule options @return [Builder] @example
Blackcal.dsl do months [:january] days 15..25 end
# File lib/blackcal/builder.rb, line 13 def self.dsl(&block) new.tap { |b| b.instance_eval(&block) } end
new()
click to toggle source
Returns a new instance of Builder
# File lib/blackcal/builder.rb, line 18 def initialize @data = {} end
Public Instance Methods
days(*days)
click to toggle source
@param days [Array<Integer>, Integer, nil]
# File lib/blackcal/builder.rb, line 58 def days(*days) @data[:days] = flat_array(days) end
finish_hour_of_day(finish_hour_of_day)
click to toggle source
@param [TimeOfDay, Time, Integer, nil] finish_hour_of_day
# File lib/blackcal/builder.rb, line 38 def finish_hour_of_day(finish_hour_of_day) @data[:finish_hour_of_day] = finish_hour_of_day end
finish_time(finish_time)
click to toggle source
@param [Time, Date, String, nil] finish_time
# File lib/blackcal/builder.rb, line 28 def finish_time(finish_time) @data[:finish_time] = finish_time end
months(*months)
click to toggle source
@param [Array<String>, Array<Symbol>, String, Symbol, nil] months
# File lib/blackcal/builder.rb, line 43 def months(*months) @data[:months] = flat_array(months) end
start_time(start_time)
click to toggle source
@param [Time, Date, String, nil] start_time
# File lib/blackcal/builder.rb, line 23 def start_time(start_time) @data[:start_time] = start_time end
start_time_of_day(start_time_of_day)
click to toggle source
@param [TimeOfDay, Time, Integer, nil] start_time_of_day
# File lib/blackcal/builder.rb, line 33 def start_time_of_day(start_time_of_day) @data[:start_time_of_day] = start_time_of_day end
to_h()
click to toggle source
The builder represented as a hash @return [Hash]
# File lib/blackcal/builder.rb, line 64 def to_h @data end
weekdays(*weekdays)
click to toggle source
@param [Array<String>, Array<Symbol>, String, Symbol, nil] weekdays
# File lib/blackcal/builder.rb, line 48 def weekdays(*weekdays) @data[:weekdays] = flat_array(weekdays) end
weeks_of_month(*weeks_of_month)
click to toggle source
@param [Array<Integer>, nil] weeks_of_month
# File lib/blackcal/builder.rb, line 53 def weeks_of_month(*weeks_of_month) @data[:weeks_of_month] = flat_array(weeks_of_month) end
Private Instance Methods
flat_array(array)
click to toggle source
# File lib/blackcal/builder.rb, line 70 def flat_array(array) Array(array).flatten(1) end