Class: Biz::Schedule

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/biz/schedule.rb

Instance Method Summary collapse

Constructor Details

#initialize(&config) ⇒ Schedule

Returns a new instance of Schedule.



8
9
10
# File 'lib/biz/schedule.rb', line 8

def initialize(&config)
  @configuration = Configuration.new(&config)
end

Instance Method Details

#&(other) ⇒ Object



57
58
59
# File 'lib/biz/schedule.rb', line 57

def &(other)
  self.class.new(&(configuration & other.configuration))
end

#datesObject Also known as: date



25
26
27
# File 'lib/biz/schedule.rb', line 25

def dates
  Dates.new(self)
end

#in_hours?(time) ⇒ Boolean Also known as: business_hours?

Returns:

  • (Boolean)


39
40
41
# File 'lib/biz/schedule.rb', line 39

def in_hours?(time)
  Calculation::Active.new(self, time).result
end

#in_zoneObject



53
54
55
# File 'lib/biz/schedule.rb', line 53

def in_zone
  Time.new(time_zone)
end

#on_break?(time) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/biz/schedule.rb', line 45

def on_break?(time)
  Calculation::OnBreak.new(self, time).result
end

#on_holiday?(time) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/biz/schedule.rb', line 49

def on_holiday?(time)
  Calculation::OnHoliday.new(self, time).result
end

#periodsObject



21
22
23
# File 'lib/biz/schedule.rb', line 21

def periods
  Periods::Proxy.new(self)
end

#time(scalar, unit) ⇒ Object



31
32
33
# File 'lib/biz/schedule.rb', line 31

def time(scalar, unit)
  Calculation::ForDuration.with_unit(self, scalar, unit)
end

#within(origin, terminus) ⇒ Object



35
36
37
# File 'lib/biz/schedule.rb', line 35

def within(origin, terminus)
  Calculation::DurationWithin.new(self, TimeSegment.new(origin, terminus))
end