Module: Workpattern
- Defined in:
- lib/workpattern.rb,
lib/workpattern/day.rb,
lib/workpattern/week.rb,
lib/workpattern/clock.rb,
lib/workpattern/version.rb,
lib/workpattern/constants.rb,
lib/workpattern/workpattern.rb,
lib/workpattern/week_pattern.rb
Overview
workpattern.rb - date calculation library that takes into account patterns of working and resting time and is aimed at supporting scheduling applications such as critical path analysis.
Author: Barrie Callender 2011
Documentation: Barrie Callender <[email protected]>
Defined Under Namespace
Classes: Clock, Day, Week, WeekPattern, Workpattern
Constant Summary collapse
- VERSION =
'0.6.0'
- DEFAULT_WORKPATTERN_NAME =
default name of a new Workpattern
'default'.freeze
- DEFAULT_BASE_YEAR =
default base year for a new workpattern
2000
- DEFAULT_SPAN =
default span of years for a new Workpattern
100
- MINUTE =
60 seconds in a minute
60
- HOUR =
60 minutes in an hour
MINUTE * 60
- HOURS_IN_DAY =
24 hours in a day
24
- DAY =
Seconds in a day
HOUR * HOURS_IN_DAY
- WORKING_HOUR =
60 minutes in a working hour as binary bit per minute
2**MINUTE - 1
- RESTING_HOUR =
0 minutes in a working hour as binary bits per minute
0
- FIRST_TIME_IN_DAY =
Earliest or first time in the day
Clock.new(0, 0)
- LAST_TIME_IN_DAY =
Latest or last time in the day
Clock.new(23, 59)
- PREVIOUS_DAY =
Flags for calculations
-1
- SAME_DAY =
0
- NEXT_DAY =
1
- WORK_TYPE =
Specifies a working pattern
1
- REST_TYPE =
Specifies a resting pattern
0
- SUNDAY =
All the days of the week
0
- MONDAY =
1
- TUESDAY =
2
- WEDNESDAY =
3
- THURSDAY =
4
- FRIDAY =
5
- SATURDAY =
6
- FIRST_DAY_OF_WEEK =
first and last day of week
SUNDAY
- LAST_DAY_OF_WEEK =
SATURDAY
- DAYNAMES =
daynames.freeze
Class Method Summary collapse
-
.clear ⇒ Object
Convenience method to delete all Workpatterns.
-
.clock(hour, min) ⇒ Clock
Convenience method to create a Clock object.
-
.delete(name) ⇒ Object
Convenience method to delete the named
Workpattern
. -
.get(name) ⇒ Workpattern
Covenience method to obtain an existing
Workpattern
. -
.new(name = DEFAULT_WORKPATTERN_NAME, base = DEFAULT_BASE_YEAR, span = DEFAULT_SPAN) ⇒ Workpattern
Covenience method to obtain a new
Workpattern
. -
.to_a ⇒ Array
Covenience method to obtain an Array of all the known
Workpattern
objects.
Class Method Details
.clear ⇒ Object
Convenience method to delete all Workpatterns.
74 75 76 |
# File 'lib/workpattern.rb', line 74 def self.clear Workpattern.clear end |
.clock(hour, min) ⇒ Clock
Convenience method to create a Clock object. This can be used for specifying times if you don’t want to create a DateTime
object
86 87 88 |
# File 'lib/workpattern.rb', line 86 def self.clock(hour, min) Clock.new(hour, min) end |
.delete(name) ⇒ Object
Convenience method to delete the named Workpattern
68 69 70 |
# File 'lib/workpattern.rb', line 68 def self.delete(name) Workpattern.delete(name) end |
.get(name) ⇒ Workpattern
Covenience method to obtain an existing Workpattern
60 61 62 |
# File 'lib/workpattern.rb', line 60 def self.get(name) Workpattern.get(name) end |
.new(name = DEFAULT_WORKPATTERN_NAME, base = DEFAULT_BASE_YEAR, span = DEFAULT_SPAN) ⇒ Workpattern
Covenience method to obtain a new Workpattern
A negative span
counts back from the base
year
40 41 42 43 44 |
# File 'lib/workpattern.rb', line 40 def self.new(name = DEFAULT_WORKPATTERN_NAME, base = DEFAULT_BASE_YEAR, span = DEFAULT_SPAN) Workpattern.new(name, base, span) end |
.to_a ⇒ Array
Covenience method to obtain an Array of all the known Workpattern
objects
51 52 53 |
# File 'lib/workpattern.rb', line 51 def self.to_a Workpattern.to_a end |