workpattern 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +4 -1
- data/.travis.yml +8 -2
- data/CHANGELOG +19 -0
- data/Gemfile +0 -0
- data/README.md +58 -57
- data/Rakefile +0 -0
- data/lib/workpattern.rb +65 -55
- data/lib/workpattern/clock.rb +17 -20
- data/lib/workpattern/utility/base.rb +16 -21
- data/lib/workpattern/version.rb +2 -2
- data/lib/workpattern/week.rb +266 -189
- data/lib/workpattern/workpattern.rb +170 -142
- data/script/console +0 -0
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/script/txt2html +0 -0
- data/test/test_clock.rb +19 -22
- data/test/test_helper.rb +0 -0
- data/test/test_week.rb +393 -368
- data/test/test_workpattern.rb +238 -207
- data/test/test_workpattern_module.rb +57 -51
- data/workpattern.gemspec +7 -6
- metadata +44 -16
- data/config/website.yml +0 -2
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MjZmZTg4OTViNzJjY2I0NGI1OTNlZjQ2NzYwZGNmZTg1ZDE4Y2JjZA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8e19f40a13975d2a07d505bce513b1d48dc25ca6
|
4
|
+
data.tar.gz: 8a974a014e365222029c333b8fee0835e91bd125
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YTJkYTRkZWQ5YjVmZTQ3N2E4YWVhZGNiZTFmNmQ2YzI1Yjc5MjY5MzU1YWRk
|
11
|
-
NTNmMDFjODY5ZTNkZDliZjBiYzY5ZDljMzkwYWY1NzA3ZjYyNDk=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
OWY5ZmM4Yzc0MmViNmY5YmZmMTE2YzFhMTVmMTA5Y2M5MzRmMmE0ZWM0YWVh
|
14
|
-
MzY3YWFkNjNlYTBkN2JjZjdmYjM3MTRhMDA4NTQ2YjQ1NGZkYmU3ZmQzMDE2
|
15
|
-
NjZlZDI5MzVjZjExNTY4YjVlZjMyMTA4ZjQxMDg0YmY2ZjE1NDI=
|
6
|
+
metadata.gz: 8bc16dcdae0b21a90952c15fde3bdcc51a7ad0dea8d28afa9e26f3afb78e76b16738690227a668e01878eb56009460f9b82f698f72ed5198d6a6156cfc375818
|
7
|
+
data.tar.gz: 757f7bc54c5247c09ca12533ed349a1aef37d47056ac4e12d98820a4ea7a94958f6d5c4256fb935278c4152159a100f10aa7a4cba54c4468ab89ea4625e73b69
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
## Workpattern v0.5.0 ( Oct 19, 2016) ##
|
2
|
+
|
3
|
+
* Workpattern now handles Timezones. It changes the date into UTC, does the calculation and then changes it back * Barrie Callender
|
4
|
+
* Removed Day class and associated tests as it is no longer used * Barrie Callender
|
5
|
+
* Reviewed the README and removed a lot of cruft and also updated it a little to demonstrate features * Barrie Callender
|
6
|
+
* Hid documentation unless it was part of the public api * Barrie Callender
|
7
|
+
* Used Rubocop to help me be more consistent. I ignored some of the offences to do with long lines/methods and classes * Barrie Callender
|
8
|
+
* Code makes use of Time objects where it use to use DateTime. Time comes with a Timezone * Barrie Callender
|
9
|
+
* Rewrote/refactored methods in the Week class - which needs refactoring into new classes * Barrie Callender
|
10
|
+
* Removed rubyforge_project from workpattern.gemspec * Barrie Callender
|
11
|
+
* Added homepage & required_ruby_version to workpattern.gemspec * Barrie Callender
|
12
|
+
* Added versions to test in Travis CI to include 1.9.3, 2.0.0, 2.1.0, 2.1.9, 2.2.0, 2.2.5, 2.3.0 & 2.3.1 * Barrie Callender
|
13
|
+
* Dealt with Travis CI issue with version of bundler * Barrie Callender
|
14
|
+
* Removed config directory & contents * Barrie Callender
|
15
|
+
* Changed Description * barrie Callender
|
16
|
+
* Specified minitest ~> 5.4.3 due to an issue I no longer recall * Barrie Callender
|
17
|
+
* Hid all the documentation apart from public api * Barrie Callender
|
18
|
+
* improved the README.md (IMHO) * Barrie Callender
|
19
|
+
|
1
20
|
## Workpattern v0.4.0 ( May 23, 2014) ##
|
2
21
|
|
3
22
|
* Updated Week class to use bits and removed Day and Hour class as a consequence * Barrie Callender *
|
data/Gemfile
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -1,102 +1,103 @@
|
|
1
1
|
# Workpattern [![Build Status](https://secure.travis-ci.org/callenb/workpattern.png)](https://secure.travis-ci.org/callenb/workpattern.png)
|
2
2
|
|
3
|
-
|
3
|
+
Calculates dates and durations whilst taking into account working and non-working times. It creates calendars similar to what you can find in project scheduling software like Microsoft project and Primavera P6.
|
4
4
|
|
5
|
-
|
5
|
+
Please use [Github Issues] to report bugs. If you have a question about the library, please use the `workpattern` tag on [Stack Overflow]. This tag is monitored by contributors.
|
6
6
|
|
7
|
-
|
7
|
+
[Github Issues]: http://github.com/callenb/workpattern/issues
|
8
|
+
[Stack Overflow]: http://stackoverflow.com/questions/tagged/workpattern
|
8
9
|
|
9
|
-
|
10
|
-
minutes to a date and returning the new `Date` or `DateTime` as the result. Although there
|
11
|
-
are 60 seconds in every minute and 60 minutes in every hour, there aren't always 24 hours in every day, and
|
12
|
-
if there was, we still wouldn't be working during all of them. We would be doing other things like eating,
|
13
|
-
sleeping, travelling and having a bit of leisure time. Workpattern refers to this time as Resting time.
|
14
|
-
It refers to the time when we're busy doing stuff as Working time.
|
10
|
+
## Getting Started
|
15
11
|
|
16
|
-
|
17
|
-
in a hospital, the working day can have anything from 0 hours to the full 24 hours. Most office based work
|
18
|
-
is something like 7.5 or 8 hours a day except weekends, public holidays and vacations when no work takes
|
19
|
-
place.
|
12
|
+
Workpattern is a library with no monkey-patching and is tested against Ruby `>= 1.9.2`.
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
14
|
+
You can install it using:
|
15
|
+
```sh
|
16
|
+
gem install workpattern
|
17
|
+
```
|
25
18
|
|
26
|
-
|
19
|
+
Or you can add it to your Gemfile with:
|
27
20
|
|
28
|
-
|
21
|
+
```sh
|
22
|
+
gem "workpattern"
|
23
|
+
```
|
29
24
|
|
30
|
-
|
25
|
+
Then run the bundle command to install it.
|
31
26
|
|
32
|
-
##
|
27
|
+
## Use
|
33
28
|
|
34
|
-
|
29
|
+
## Configure and Calculate
|
30
|
+
|
31
|
+
First create a `Workpattern` to hold all the working and resting times.
|
35
32
|
|
36
33
|
``` ruby
|
37
|
-
mywp=Workpattern.new
|
34
|
+
mywp=Workpattern.new 'My Workpattern',2011,10
|
38
35
|
```
|
36
|
+
That line created a `Workpattern` called `My Workpattern` starting on 1-Jan-2011 and continuing for `10` years until `2020`.
|
39
37
|
|
40
|
-
|
38
|
+
`mywp` is created with a 24 hour a day working time. Next step is to tell it to ignore weekends by making every Saturday and Sunday non-working.
|
41
39
|
|
42
40
|
``` ruby
|
43
|
-
mywp.resting
|
41
|
+
mywp.resting :days => :weekend
|
44
42
|
```
|
45
43
|
|
46
|
-
|
44
|
+
The `Workpattern.clock` method can be used to specify the non-working times for each weekday. Any class that responds to `#hour` and `#min` methods such as `Time` or `DateTime` can be used instead of `Workpattern.clock`.
|
47
45
|
|
48
46
|
``` ruby
|
49
|
-
mywp.resting
|
50
|
-
mywp.resting
|
51
|
-
mywp.resting
|
47
|
+
mywp.resting :days =>:weekday, :from_time=>Workpattern.clock(0,0),:to_time=>Workpattern.clock(8,59)
|
48
|
+
mywp.resting :days =>:weekday, :from_time=>Workpattern.clock(12,0),:to_time=>Workpattern.clock(12,59)
|
49
|
+
mywp.resting :days =>:weekday, :from_time=>Workpattern.clock(18,0),:to_time=>Workpattern.clock(23,59)
|
52
50
|
```
|
51
|
+
As well as `:weekend` and `:weekday` it is possible to use `:mon`, `:tue`, `:wed`, `:thu`, `:fri`, `:sat`, `:sun` or `all`.
|
53
52
|
|
54
|
-
|
53
|
+
With `mywp` setup, the `#calc` method is used to add 32 hours which must be supplied as the number of whole minutes (1920) to a date.
|
55
54
|
|
56
55
|
``` ruby
|
57
|
-
|
58
|
-
result_date = mywp.calc
|
56
|
+
my_date=Time.gm 2011,9,1,9,0
|
57
|
+
result_date = mywp.calc my_date,1920 # => 6/9/11@18:00
|
59
58
|
```
|
60
59
|
|
61
|
-
|
60
|
+
The result takes into account the non-working or resting times.
|
61
|
+
|
62
|
+
Subtracting a date is just as easy by using a negative number of minutes in `#calc`.
|
62
63
|
|
63
|
-
|
64
|
-
* Direct questions and discussions to the [mailing list](http://groups.google.com/group/workpattern).
|
65
|
-
* Report issues on [GitHub Issues](http://github.com/callenb/workpattern/issues).
|
66
|
-
* Pull requests are very welcome, however I have never participated in Open Source so will be a bit slow as I am learning. Please be patient with me. Please include spec and/or feature coverage for every patch, and create a topic branch for every separate change you make.
|
67
|
-
* Advice, such as pointing out how I should really code in Ruby will be gratefully received.
|
64
|
+
Finding the duration between two dates is also easy using the `#diff` method.
|
68
65
|
|
69
|
-
|
66
|
+
``` ruby
|
67
|
+
diff_result = mywp.diff my_date, result_date # => 1920
|
68
|
+
```
|
70
69
|
|
71
|
-
|
72
|
-
it. At the moment it can perform the following:
|
70
|
+
Vacations can be added to the `Workpattern` using the `#resting` method:
|
73
71
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
72
|
+
``` ruby
|
73
|
+
mywp.resting :days => :all, :start => DateTime.civil(2011,5,1), :finish => DateTime.civil(2011,5,7)
|
74
|
+
```
|
75
|
+
Find out if a specific date and time is working or not.
|
78
76
|
|
79
|
-
|
80
|
-
|
77
|
+
``` ruby
|
78
|
+
mydate = DateTime.civil 2011,5,2,9,10
|
79
|
+
mywp.resting? mydate # => true
|
80
|
+
mywp.working? mydate # => false
|
81
|
+
```
|
81
82
|
|
82
|
-
|
83
|
+
### Manage
|
83
84
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
* Extract patterns from the workpattern so they can be persisted in a database.
|
88
|
-
* Decide how to handle different Timezones apart from UTC.
|
85
|
+
``` ruby
|
86
|
+
# Fetch a specific Workpattern
|
87
|
+
Workpattern.get "My Workpattern"
|
89
88
|
|
90
|
-
|
89
|
+
# Delete a specific Workpattern
|
90
|
+
Workpattern.delete "My Workpattern"
|
91
91
|
|
92
|
-
|
93
|
-
|
92
|
+
# Delete all Workpatterns
|
93
|
+
Workpattern.clear
|
94
|
+
```
|
94
95
|
|
95
96
|
## License
|
96
97
|
|
97
98
|
(The MIT License)
|
98
99
|
|
99
|
-
Copyright (c) 2012
|
100
|
+
Copyright (c) 2012 - 2016
|
100
101
|
|
101
102
|
Permission is hereby granted, free of charge, to any person obtaining
|
102
103
|
a copy of this software and associated documentation files (the
|
data/Rakefile
CHANGED
File without changes
|
data/lib/workpattern.rb
CHANGED
@@ -3,107 +3,117 @@
|
|
3
3
|
#
|
4
4
|
# email: barrie@callenb.org
|
5
5
|
#++
|
6
|
-
|
7
|
-
|
6
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__)) unless
|
7
|
+
$LOAD_PATH.include?(File.dirname(__FILE__)) || $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
|
8
8
|
|
9
9
|
require 'rubygems'
|
10
10
|
require 'date'
|
11
11
|
require 'workpattern/utility/base.rb'
|
12
12
|
require 'workpattern/clock'
|
13
|
+
#require 'workpattern/day'
|
13
14
|
require 'workpattern/week'
|
14
15
|
require 'workpattern/workpattern'
|
15
16
|
|
16
17
|
#
|
17
18
|
# workpattern.rb - date calculation library that takes into account patterns of
|
18
|
-
# working and resting time and is aimed at supporting scheduling applications
|
19
|
-
# as critical path analysis.
|
19
|
+
# working and resting time and is aimed at supporting scheduling applications
|
20
|
+
# such as critical path analysis.
|
20
21
|
#
|
21
22
|
# Author: Barrie Callender 2011
|
22
23
|
#
|
23
24
|
# Documentation: Barrie Callender <barrie@callenb.org>
|
24
25
|
#
|
25
26
|
module Workpattern
|
26
|
-
|
27
27
|
# Represents a full working hour
|
28
28
|
# @since 0.2.0
|
29
|
-
WORKING_HOUR = 2**60-1
|
30
|
-
|
29
|
+
WORKING_HOUR = 2**60 - 1
|
30
|
+
|
31
31
|
# Represents a full resting hour
|
32
|
-
# @since 0.2.0
|
32
|
+
# @since 0.2.0
|
33
33
|
RESTING_HOUR = 0
|
34
|
-
|
34
|
+
|
35
35
|
# The default workpattern name
|
36
|
-
# @since 0.2.0
|
37
|
-
DEFAULT_WORKPATTERN_NAME = 'default'
|
38
|
-
|
36
|
+
# @since 0.2.0
|
37
|
+
DEFAULT_WORKPATTERN_NAME = 'default'.freeze
|
38
|
+
|
39
39
|
# The default base year
|
40
40
|
# @since 0.2.0
|
41
41
|
DEFAULT_BASE_YEAR = 2000
|
42
|
-
|
42
|
+
|
43
43
|
# The default span in years
|
44
44
|
# @since 0.2.0
|
45
45
|
DEFAULT_SPAN = 100
|
46
|
-
|
47
|
-
#
|
48
|
-
#
|
49
|
-
|
50
|
-
|
51
|
-
#
|
52
|
-
#
|
53
|
-
|
54
|
-
|
46
|
+
|
47
|
+
# Minute in terms of seconds
|
48
|
+
#
|
49
|
+
MINUTE = 60
|
50
|
+
|
51
|
+
# Hour interms od seconds
|
52
|
+
#
|
53
|
+
HOUR = MINUTE * 60
|
54
|
+
|
55
|
+
# Day in terms of seconds
|
56
|
+
#
|
57
|
+
DAY = HOUR * 24
|
58
|
+
|
55
59
|
# Earliest or first time in the day
|
56
60
|
# @since 0.0.1
|
57
|
-
FIRST_TIME_IN_DAY=Clock.new(0,0)
|
58
|
-
|
61
|
+
FIRST_TIME_IN_DAY = Clock.new(0, 0)
|
62
|
+
|
59
63
|
# Latest or last time in the day
|
60
64
|
# @since 0.0.1
|
61
|
-
LAST_TIME_IN_DAY=Clock.new(23,59)
|
62
|
-
|
65
|
+
LAST_TIME_IN_DAY = Clock.new(23, 59)
|
66
|
+
|
63
67
|
# Specifies a working pattern
|
64
68
|
# @since 0.0.1
|
65
69
|
WORK = 1
|
66
|
-
|
70
|
+
|
67
71
|
# Specifies a resting pattern
|
68
72
|
# @since 0.0.1
|
69
73
|
REST = 0
|
70
|
-
|
71
|
-
# Represents the days of the week to be used in applying working
|
72
|
-
#
|
74
|
+
|
75
|
+
# Represents the days of the week to be used in applying working
|
76
|
+
# and resting patterns.
|
77
|
+
# Values exist for each day of the week as well as for the weekend
|
78
|
+
# (Saturday and Sunday),
|
73
79
|
# the week (Monday to Friday) and all days in the week.
|
74
80
|
#
|
75
81
|
# @since 0.0.1
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
+
daynames = { sun: [0], mon: [1], tue: [2], wed: [3],
|
83
|
+
thu: [4], fri: [5], sat: [6],
|
84
|
+
weekday: [1, 2, 3, 4, 5],
|
85
|
+
weekend: [0, 6],
|
86
|
+
all: [0, 1, 2, 3, 4, 5, 6] }
|
87
|
+
DAYNAMES = daynames.freeze
|
88
|
+
# Covenience method to obtain a new <tt>Workpattern</tt>
|
82
89
|
#
|
83
90
|
# A negative <tt>span</tt> counts back from the <tt>base</tt> year
|
84
91
|
#
|
85
92
|
# @param [String] name Every workpattern has a unique name.
|
86
93
|
# @param [Integer] base Workpattern starts on the 1st January of this year.
|
87
|
-
# @param [Integer]
|
94
|
+
# @param [Integer] number of years ending on 31st December.
|
88
95
|
# @return [Workpattern]
|
89
|
-
# @raise [NameError]
|
96
|
+
# @raise [NameError] creating a Workpattern with a name that already exists
|
90
97
|
# @since 0.2.0
|
91
98
|
#
|
92
|
-
def self.new(name=DEFAULT_WORKPATTERN_NAME,
|
93
|
-
|
99
|
+
def self.new(name = DEFAULT_WORKPATTERN_NAME,
|
100
|
+
base = DEFAULT_BASE_YEAR,
|
101
|
+
span = DEFAULT_SPAN)
|
102
|
+
Workpattern.new(name, base, span)
|
94
103
|
end
|
95
|
-
|
96
|
-
# Covenience method to obtain an Array of all the known <tt>Workpattern</tt>
|
104
|
+
|
105
|
+
# Covenience method to obtain an Array of all the known <tt>Workpattern</tt>
|
106
|
+
# objects
|
97
107
|
#
|
98
108
|
# @return [Array] all <tt>Workpattern</tt> objects
|
99
109
|
#
|
100
110
|
# @since 0.2.0
|
101
111
|
#
|
102
|
-
def self.to_a
|
103
|
-
|
112
|
+
def self.to_a
|
113
|
+
Workpattern.to_a
|
104
114
|
end
|
105
115
|
|
106
|
-
# Covenience method to obtain an existing <tt>Workpattern</tt>
|
116
|
+
# Covenience method to obtain an existing <tt>Workpattern</tt>
|
107
117
|
#
|
108
118
|
# @param [String] name The name of the Workpattern to retrieve.
|
109
119
|
# @return [Workpattern]
|
@@ -111,9 +121,9 @@ module Workpattern
|
|
111
121
|
# @since 0.2.0
|
112
122
|
#
|
113
123
|
def self.get(name)
|
114
|
-
|
124
|
+
Workpattern.get(name)
|
115
125
|
end
|
116
|
-
|
126
|
+
|
117
127
|
# Convenience method to delete the named <tt>Workpattern</tt>
|
118
128
|
#
|
119
129
|
# @param [String] name The name of the Workpattern to be deleted.
|
@@ -123,18 +133,18 @@ module Workpattern
|
|
123
133
|
def self.delete(name)
|
124
134
|
Workpattern.delete(name)
|
125
135
|
end
|
126
|
-
|
136
|
+
|
127
137
|
# Convenience method to delete all Workpatterns.
|
128
|
-
#
|
138
|
+
#
|
129
139
|
# @since 0.2.0
|
130
140
|
#
|
131
141
|
def self.clear
|
132
142
|
Workpattern.clear
|
133
143
|
end
|
134
|
-
|
135
|
-
# Convenience method to create a Clock object. This can be used for
|
136
|
-
# if you don't want to create a <tt>DateTime</tt> object
|
137
|
-
#
|
144
|
+
|
145
|
+
# Convenience method to create a Clock object. This can be used for
|
146
|
+
# specifying times if you don't want to create a <tt>DateTime</tt> object
|
147
|
+
#
|
138
148
|
# @param [Integer] hour the number of hours.
|
139
149
|
# @param [Integer] min the number of minutes
|
140
150
|
# @return [Clock]
|
@@ -142,7 +152,7 @@ module Workpattern
|
|
142
152
|
#
|
143
153
|
# @since 0.2.0
|
144
154
|
#
|
145
|
-
def self.clock(hour,min)
|
146
|
-
|
155
|
+
def self.clock(hour, min)
|
156
|
+
Clock.new(hour, min)
|
147
157
|
end
|
148
158
|
end
|
data/lib/workpattern/clock.rb
CHANGED
@@ -7,7 +7,7 @@ module Workpattern
|
|
7
7
|
# myClock.hour #=> 3
|
8
8
|
# myClock.min #=> 32
|
9
9
|
# myClock.time #=> Time.new(1963,6,10,3,32)
|
10
|
-
# myClock.to_s #=> 3:32 212
|
10
|
+
# myClock.to_s #=> 3:32 212
|
11
11
|
#
|
12
12
|
# aClock=Clock.new(27,80)
|
13
13
|
# aClock.minutes #=> 1700
|
@@ -19,64 +19,61 @@ module Workpattern
|
|
19
19
|
# @since 0.2.0
|
20
20
|
#
|
21
21
|
class Clock
|
22
|
-
|
23
|
-
#
|
24
|
-
# or 0 if they are absent. Although there are 24 hours in a day
|
22
|
+
# Initialises an instance of <tt>Clock</tt> using the hours and minutes
|
23
|
+
# supplied or 0 if they are absent. Although there are 24 hours in a day
|
25
24
|
# (0-23) and 60 minutes in an hour (0-59), <tt>Clock</tt> calculates
|
26
25
|
# the full hours and remaining minutes of whatever is supplied.
|
27
26
|
#
|
28
27
|
# @param [Integer] hour number of hours
|
29
28
|
# @param [Integer] min number of minutes
|
30
29
|
#
|
31
|
-
def initialize(hour=0,min=0)
|
32
|
-
@hour = total_minutes(hour,min).div(60)
|
33
|
-
@min = total_minutes(hour,min) % 60
|
30
|
+
def initialize(hour = 0, min = 0)
|
31
|
+
@hour = total_minutes(hour, min).div(60)
|
32
|
+
@min = total_minutes(hour, min) % 60
|
34
33
|
end
|
35
|
-
|
34
|
+
|
36
35
|
# Returns the total number of minutes
|
37
36
|
#
|
38
37
|
# @return [Integer] total minutes represented by the Clock object
|
39
38
|
#
|
40
39
|
def minutes
|
41
|
-
|
40
|
+
total_minutes(@hour, @min)
|
42
41
|
end
|
43
|
-
|
42
|
+
|
44
43
|
# Returns the hour of the clock (0-23)
|
45
44
|
#
|
46
45
|
# @return [Integer] hour of Clock from 0 to 23.
|
47
46
|
#
|
48
47
|
def hour
|
49
|
-
|
48
|
+
@hour % 24
|
50
49
|
end
|
51
|
-
|
50
|
+
|
52
51
|
# Returns the minute of the clock (0-59)
|
53
52
|
#
|
54
53
|
# @return [Integer] minute of Clock from 0 to 59
|
55
54
|
#
|
56
55
|
def min
|
57
|
-
|
56
|
+
@min % 60
|
58
57
|
end
|
59
|
-
|
58
|
+
|
60
59
|
# Returns a <tt>Time</tt> object with the correct
|
61
60
|
# <tt>hour</tt> and <tt>min</tt> values. The date
|
62
61
|
# is 10th June 1963.
|
63
62
|
#
|
64
63
|
# @return [DateTime] The time using the date of 10th June 1963 (My Birthday)
|
65
64
|
def time
|
66
|
-
|
65
|
+
DateTime.new(1963, 6, 10, hour, min)
|
67
66
|
end
|
68
|
-
|
69
67
|
|
70
68
|
# @return [String] representation of <tt>Clock</tt> value as 'hh:mn minutes'
|
71
|
-
def to_s
|
69
|
+
def to_s
|
72
70
|
hour.to_s.concat(':').concat(min.to_s).concat(' ').concat(minutes.to_s)
|
73
71
|
end
|
74
|
-
|
72
|
+
|
75
73
|
private
|
76
74
|
|
77
75
|
def total_minutes(hours, mins)
|
78
|
-
|
76
|
+
(hours * 60) + mins
|
79
77
|
end
|
80
|
-
|
81
78
|
end
|
82
79
|
end
|