Move to Apache License
[amazing.git] / lib / amazing / numeric.rb
blobc596c72aa7524407eb8507db5362fc060c9cddef
1 # Copyright 2008 Dag Odenhall <dag.odenhall@gmail.com>
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 #    http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 class Numeric
16   def seconds
17     self
18   end
19   alias :second :seconds
21   def minutes
22     self * 60
23   end
24   alias :minute :minutes
26   def hours
27     minutes * 60
28   end
29   alias :hour :hours
31   def days
32     hours * 24
33   end
34   alias :day :days
36   def weeks
37     days * 7
38   end
39   alias :week :weeks
41   def months
42     weeks * 4
43   end
44   alias :month :months
46   def years
47     months * 12
48   end
49   alias :year :years
50 end