Class: Biz::Configuration
- Inherits:
-
Object
- Object
- Biz::Configuration
- Includes:
- Memoizable
- Defined in:
- lib/biz/configuration.rb
Defined Under Namespace
Classes: Raw
Instance Method Summary collapse
- #holidays ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #intervals ⇒ Object
- #time_zone ⇒ Object
- #weekdays ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
6 7 8 |
# File 'lib/biz/configuration.rb', line 6 def initialize @raw = Raw.new.tap do |raw| yield raw if block_given? end end |
Instance Method Details
#holidays ⇒ Object
16 17 18 |
# File 'lib/biz/configuration.rb', line 16 def holidays raw.holidays.map { |date| Holiday.new(date, time_zone) } end |
#intervals ⇒ Object
10 11 12 13 14 |
# File 'lib/biz/configuration.rb', line 10 def intervals raw.hours.flat_map { |weekday, hours| weekday_intervals(weekday, hours) }.sort_by(&:start_time) end |
#time_zone ⇒ Object
20 21 22 |
# File 'lib/biz/configuration.rb', line 20 def time_zone TZInfo::TimezoneProxy.new(raw.time_zone) end |
#weekdays ⇒ Object
24 25 26 |
# File 'lib/biz/configuration.rb', line 24 def weekdays raw.hours.keys.to_set end |