human_time 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/human_time.rb +29 -19
- data/lib/human_time/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 569f9bd7d07547f793e141863a5bd02a7f1195a6
|
4
|
+
data.tar.gz: cfb38acf4ef632549669b4dafed28c5e1650f434
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd4a0d9ca114f8c9d5225db14881676595be0732eb69f5b93bd16abafb2a6ccd38ee7ceccd49f142f8245c4ffeabf49ee98c1fc70ed75bebf59c27745dc68f11
|
7
|
+
data.tar.gz: 7bd68769f2b4ebfd0a2064186892de507432f357891945def07a3f298340acab61d4d70d0b0749545c557d248fda1e8106c65d569b72affa277814edf1153654
|
data/lib/human_time.rb
CHANGED
@@ -4,33 +4,43 @@ require 'time'
|
|
4
4
|
require "human_time/version"
|
5
5
|
|
6
6
|
module HumanTime
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
class << self
|
8
|
+
def greater_than_aliases
|
9
|
+
%w{newer_than? more_recent_than? comes_after? later_than?}
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
def greater_than_or_equal_to_aliases
|
13
|
+
%w{newer_than_or_equal_to? more_recent_than_or_equal_to? after_or_equal_to? later_than_or_equal_to?}
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
def less_than_aliases
|
17
|
+
%w{older_than? comes_before? earlier_than?}
|
18
|
+
end
|
19
|
+
|
20
|
+
def less_than_or_equal_to_aliases
|
21
|
+
%w{older_than_or_equal_to? before_or_equal_to? earlier_than_or_equal_to?}
|
22
|
+
end
|
18
23
|
|
19
|
-
|
20
|
-
|
24
|
+
def included(base)
|
25
|
+
add_alias(base, greater_than_aliases, :>)
|
26
|
+
add_alias(base, greater_than_or_equal_to_aliases, :>=)
|
27
|
+
add_alias(base, less_than_aliases, :<)
|
28
|
+
add_alias(base, less_than_or_equal_to_aliases, :<=)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def add_alias(base, aliases, op)
|
34
|
+
aliases.each{ |ali| base.send :alias_method, ali, op }
|
35
|
+
end
|
21
36
|
end
|
37
|
+
|
22
38
|
end
|
23
39
|
|
24
40
|
class Date
|
25
|
-
HumanTime
|
26
|
-
HumanTime.greater_than_or_equal_to_aliases.each{ |ali| alias_method ali, :>= }
|
27
|
-
HumanTime.less_than_aliases.each{ |ali| alias_method ali, :< }
|
28
|
-
HumanTime.less_than_or_equal_to_aliases.each{ |ali| alias_method ali, :<= }
|
41
|
+
include HumanTime
|
29
42
|
end
|
30
43
|
|
31
44
|
class Time
|
32
|
-
HumanTime
|
33
|
-
HumanTime.greater_than_or_equal_to_aliases.each{ |ali| alias_method ali, :>= }
|
34
|
-
HumanTime.less_than_aliases.each{ |ali| alias_method ali, :< }
|
35
|
-
HumanTime.less_than_or_equal_to_aliases.each{ |ali| alias_method ali, :<= }
|
45
|
+
include HumanTime
|
36
46
|
end
|
data/lib/human_time/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: human_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|