numeric-time 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/LICENSE +22 -0
- data/README.md +35 -0
- data/lib/numeric-time.rb +16 -0
- data/numeric-time.gemspec +15 -0
- metadata +51 -0
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Morion Black
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Numeric
|
2
|
+
|
3
|
+
Gem extending Numeric class and add .min, .days etc methods for Numeric objets(like Fixnum)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'numeric-time'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install numeric-time
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
require "numeric-time"
|
22
|
+
|
23
|
+
...
|
24
|
+
|
25
|
+
now = Time.now # => 2012-04-03 19:48:55 +0300
|
26
|
+
|
27
|
+
past = now - 2.days # => 2012-04-01 19:48:55 +0300
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/lib/numeric-time.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
class Numeric
|
2
|
+
|
3
|
+
def milliseconds; self/1000.0; end
|
4
|
+
def seconds; self; end
|
5
|
+
def minutes; self*60; end
|
6
|
+
def hours; self*60*60; end
|
7
|
+
def days; self*60*60*24; end
|
8
|
+
def weeks; self*60*60*24*7; end
|
9
|
+
|
10
|
+
def to_milliseconds; self*1000.0; end
|
11
|
+
def to_seconds; self; end
|
12
|
+
def to_minutes; self/60.0; end
|
13
|
+
def to_hours; self/(60*60.0); end
|
14
|
+
def to_days; self/(60*60*24.0); end
|
15
|
+
def to_weeks; self/(60*60*24*7.0); end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |gem|
|
3
|
+
gem.authors = ["InViZz"]
|
4
|
+
gem.email = ["morion.estariol@gmail.com"]
|
5
|
+
gem.description = %q{Gem extending Numeric class and add .min, .days etc methods for Numeric objets(like Fixnum)}
|
6
|
+
gem.summary = %q{Gem extending Numeric class}
|
7
|
+
gem.homepage = "https://github.com/InViZz/numeric-time/"
|
8
|
+
|
9
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
10
|
+
gem.files = `git ls-files`.split("\n")
|
11
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
12
|
+
gem.name = "numeric-time"
|
13
|
+
gem.require_paths = ["lib"]
|
14
|
+
gem.version = "0.1"
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: numeric-time
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- InViZz
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-03 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Gem extending Numeric class and add .min, .days etc methods for Numeric
|
15
|
+
objets(like Fixnum)
|
16
|
+
email:
|
17
|
+
- morion.estariol@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
25
|
+
- lib/numeric-time.rb
|
26
|
+
- numeric-time.gemspec
|
27
|
+
homepage: https://github.com/InViZz/numeric-time/
|
28
|
+
licenses: []
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
requirements: []
|
46
|
+
rubyforge_project:
|
47
|
+
rubygems_version: 1.8.17
|
48
|
+
signing_key:
|
49
|
+
specification_version: 3
|
50
|
+
summary: Gem extending Numeric class
|
51
|
+
test_files: []
|