age 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -0
- data/Gemfile +1 -0
- data/Rakefile +10 -1
- data/age.gemspec +1 -0
- data/lib/age.rb +28 -3
- data/lib/age/version.rb +2 -2
- data/test/test_age.rb +17 -0
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ccc9f1398b1000fd73bed91eed7e8deb8433fa3
|
4
|
+
data.tar.gz: 72cc3700d31f4d1bf341b5465507e4b02b73c0f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fd9af9ec3f1882967e15b2fbe8dd4ca0bf03a05551318cd58669d156e95c002a0adca1441406b618952f6911b11d9b034828bbab236d89965b35bfd40b70379
|
7
|
+
data.tar.gz: 9def0c60cb890c59f908994f0753ee8807da676c4f07489e1aede6fb041e91d97b794a2967049df4ef1fcad5288cb008d5e0dd6b7ba5bcc79759d0fc387c5c6b
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/age.gemspec
CHANGED
data/lib/age.rb
CHANGED
@@ -1,5 +1,30 @@
|
|
1
|
-
require
|
1
|
+
require 'age/version'
|
2
|
+
require 'date'
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
class Age
|
5
|
+
attr_accessor :birth, :end
|
6
|
+
|
7
|
+
def initialize(options)
|
8
|
+
@birth = options[:birth] || DateTime.now.offset(0)
|
9
|
+
@end = options[:end] || DateTime.now.offset(0)
|
10
|
+
end
|
11
|
+
|
12
|
+
def years
|
13
|
+
leep_year = 2004
|
14
|
+
end_with_leep_year = DateTime.new(leep_year, @end.month, @end.day, @end.hour, @end.min, @end.sec)
|
15
|
+
birth_with_leep_year = DateTime.new(leep_year, @birth.month, @birth.day, @birth.hour, @birth.min, @birth.sec)
|
16
|
+
if end_with_leep_year < birth_with_leep_year
|
17
|
+
@end.year - @birth.year - 1
|
18
|
+
else
|
19
|
+
@end.year - @birth.year
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_i
|
24
|
+
years
|
25
|
+
end
|
26
|
+
|
27
|
+
def inspect
|
28
|
+
years.inspect
|
29
|
+
end
|
5
30
|
end
|
data/lib/age/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.0.
|
1
|
+
class Age
|
2
|
+
VERSION = "0.0.3"
|
3
3
|
end
|
data/test/test_age.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#coding: utf-8
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'age'
|
4
|
+
|
5
|
+
class TestAge < MiniTest::Unit::TestCase
|
6
|
+
def test_sanemat
|
7
|
+
assert_equal Age.new(birth: DateTime.new(1982, 7, 16), end: DateTime.new(2013, 5, 24)).to_i, 30
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_ruby
|
11
|
+
assert_equal Age.new(birth: DateTime.new(1993, 2, 24), end: DateTime.new(2013, 5, 31)).to_i, 20
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_inspect
|
15
|
+
assert_equal Age.new(birth: DateTime.new(1993, 2, 24), end: DateTime.new(2013, 5, 31)).inspect, '20'
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: age
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sanemat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Show your age.
|
42
56
|
email:
|
43
57
|
- o.gata.ken@gmail.com
|
@@ -46,6 +60,7 @@ extensions: []
|
|
46
60
|
extra_rdoc_files: []
|
47
61
|
files:
|
48
62
|
- .gitignore
|
63
|
+
- .travis.yml
|
49
64
|
- Gemfile
|
50
65
|
- LICENSE.txt
|
51
66
|
- README.md
|
@@ -53,6 +68,7 @@ files:
|
|
53
68
|
- age.gemspec
|
54
69
|
- lib/age.rb
|
55
70
|
- lib/age/version.rb
|
71
|
+
- test/test_age.rb
|
56
72
|
homepage: ''
|
57
73
|
licenses:
|
58
74
|
- MIT
|
@@ -77,4 +93,5 @@ rubygems_version: 2.0.2
|
|
77
93
|
signing_key:
|
78
94
|
specification_version: 4
|
79
95
|
summary: Show your age.
|
80
|
-
test_files:
|
96
|
+
test_files:
|
97
|
+
- test/test_age.rb
|