my_age 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -7
- data/lib/my_age.rb +3 -2
- data/lib/my_age/cli.rb +0 -1
- data/lib/my_age/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: 2f67fc7c50a8236d6096d02eae9a37030f7fedd3
|
4
|
+
data.tar.gz: 27f63a0490f82dfbadafcd0d6b81ae159e733a18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5fd15d4cf141055360511e20345bac46ab8dafd5ba3634f3ee6e7e0982962d6d2f4b5c9599d808b901b2fa5359f816b9cd7c18028ae56d96064ee65a346b9bc
|
7
|
+
data.tar.gz: 69067448a2f89eedefb7d0faf3fcbebe14c68aad17ed17bef51b8b7c63093d0fb9165b10def25183cbafb7b3d1c68011e5730f6d950ad24a6fe9562775c7bca1
|
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
Mixin
|
21
|
+
Mixin `MyAge` module and call `age` method. It assumes your class has an attribute called `dob` that stores the date of birth.
|
22
22
|
|
23
23
|
```
|
24
24
|
class User
|
@@ -31,29 +31,29 @@ user = User.new
|
|
31
31
|
user.age
|
32
32
|
## but you can supply a specific date
|
33
33
|
user.age(date)
|
34
|
-
## there
|
34
|
+
## there is a host of helpers starting with 'age_as_of_' to specify the date too
|
35
35
|
user.age_as_of_tomorrow
|
36
36
|
```
|
37
37
|
|
38
|
-
If your date-of-birth attribute is not called `dob`, you can assign it
|
38
|
+
If your date-of-birth attribute is not called `dob`, you can assign it using `my_dob` so the gem knows where to look for it.
|
39
39
|
|
40
40
|
```
|
41
41
|
class User
|
42
42
|
attr_accessor :date_of_birth
|
43
43
|
include MyAge
|
44
|
-
my_dob :
|
44
|
+
my_dob :date_of_birth #my attribute name
|
45
45
|
end
|
46
46
|
|
47
47
|
##everything else is the same
|
48
48
|
```
|
49
49
|
## Use ActiveSupport Helpers
|
50
|
-
You can use the helpers in `
|
50
|
+
You can use the helpers in `active_support/core_ext/date/calculations`. Methods are constructed like `age_as_of_helper`. All dates specified this way are relative to today.
|
51
51
|
|
52
52
|
```
|
53
|
-
## with #end_of_month, you can
|
53
|
+
## with #end_of_month, you can call
|
54
54
|
user.age_as_of_end_of_month
|
55
55
|
|
56
|
-
##
|
56
|
+
## this gives you the age as of 9 months later from today
|
57
57
|
user.age_as_of_months_since(9)
|
58
58
|
|
59
59
|
## to be explicit, you can call
|
data/lib/my_age.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require "active_support/core_ext/
|
1
|
+
require 'active_support'
|
2
|
+
require "active_support/core_ext/object/blank"
|
3
|
+
require "active_support/core_ext/date/calculations"
|
3
4
|
require "my_age/version"
|
4
5
|
require "my_age/calculator"
|
5
6
|
require "my_age/helper"
|
data/lib/my_age/cli.rb
CHANGED
data/lib/my_age/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_age
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|