Module: Workpattern
- Defined in:
- lib/workpattern.rb,
lib/workpattern/week.rb,
lib/workpattern/clock.rb,
lib/workpattern/version.rb,
lib/workpattern/workpattern.rb,
lib/workpattern/utility/base.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
Modules: Base Classes: Clock, Week, Workpattern
Constant Summary collapse
- WORKING_HOUR =
Represents a full working hour
2**60 - 1
- RESTING_HOUR =
Represents a full resting hour
0
- DEFAULT_WORKPATTERN_NAME =
The default workpattern name
'default'.freeze
- DEFAULT_BASE_YEAR =
The default base year
2000
- DEFAULT_SPAN =
The default span in years
100
- MINUTE =
Minute in terms of seconds
60
- HOUR =
Hour interms od seconds
MINUTE * 60
- DAY =
Day in terms of seconds
HOUR * 24
- 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)
- WORK =
Specifies a working pattern
1
- REST =
Specifies a resting pattern
0
- DAYNAMES =
daynames.freeze
- VERSION =
'0.5.0'.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.
141 142 143 |
# File 'lib/workpattern.rb', line 141 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
155 156 157 |
# File 'lib/workpattern.rb', line 155 def self.clock(hour, min) Clock.new(hour, min) end |
.delete(name) ⇒ Object
Convenience method to delete the named Workpattern
133 134 135 |
# File 'lib/workpattern.rb', line 133 def self.delete(name) Workpattern.delete(name) end |
.get(name) ⇒ Workpattern
Covenience method to obtain an existing Workpattern
123 124 125 |
# File 'lib/workpattern.rb', line 123 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
99 100 101 102 103 |
# File 'lib/workpattern.rb', line 99 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
112 113 114 |
# File 'lib/workpattern.rb', line 112 def self.to_a Workpattern.to_a end |