iceland 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -2
- data/lib/iceland/version.rb +1 -1
- data/lib/iceland.rb +19 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95b30f1477b431842ba1b7aec7b3c6be294c6292
|
4
|
+
data.tar.gz: 60ef980798f7a838bf414d71515102afa83c2f0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7124e9c2324f5d529664e6aac438d2d850a45cee3a0bf683b51b001e499ef9dfb4cf352939c0b683fb5865853564a15896fb833e1d06e091586249d2b443a184
|
7
|
+
data.tar.gz: 31dc4830e351222cc4ad901cddbc9f82d5628fe4bff5250e1ef5d003961d2e50a130fa6d6ea909069fff8bd8c20b40ae37a10b66e962b73931873b7bc8c80917
|
data/README.md
CHANGED
@@ -69,15 +69,22 @@ f = Kennitala.new('010130-2979')
|
|
69
69
|
k.to_s
|
70
70
|
# => "0101302989"
|
71
71
|
|
72
|
-
# Get the entity type (results in 'person' or '
|
72
|
+
# Get the entity type (results in 'person' or 'company')
|
73
73
|
k.entity_type
|
74
74
|
# => "person"
|
75
75
|
|
76
|
+
# It's also possible to use .is_company and .is_person to achieve the same thing
|
77
|
+
k.is_company?
|
78
|
+
# => false
|
79
|
+
|
80
|
+
k.is_person?
|
81
|
+
# => true
|
82
|
+
|
76
83
|
# Get the birth date or registration day as a Date object
|
77
84
|
k.to_date
|
78
85
|
# => #<Date: 1930-01-01 ((2425978j,0s,0n),+0s,2299161j)>
|
79
86
|
|
80
|
-
# Get the current age of entity. Useful for age restrictions.
|
87
|
+
# Get the current age of the entity. Useful for age restrictions.
|
81
88
|
k.age
|
82
89
|
# => 86
|
83
90
|
```
|
@@ -103,6 +110,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
103
110
|
|
104
111
|
Bug reports and pull requests are welcome on GitHub at https://github.com/stefanvignir/iceland_gem.
|
105
112
|
|
113
|
+
Do make sure that the `rspec` unit tests run before sending a pull request and write tests for any new functionality you add.
|
114
|
+
|
106
115
|
## License
|
107
116
|
|
108
117
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/lib/iceland/version.rb
CHANGED
data/lib/iceland.rb
CHANGED
@@ -62,6 +62,25 @@ class Kennitala
|
|
62
62
|
date_integer = @value[0, 2].to_i
|
63
63
|
return 'person' if date_integer < 32
|
64
64
|
return 'company' if (date_integer > 40) && (date_integer < 71)
|
65
|
+
false
|
66
|
+
end
|
67
|
+
|
68
|
+
# Check if the entity is a company
|
69
|
+
#
|
70
|
+
# @return [Boolean]
|
71
|
+
def company?
|
72
|
+
date_integer = @value[0, 2].to_i
|
73
|
+
return true if (date_integer > 40) && (date_integer < 71)
|
74
|
+
false
|
75
|
+
end
|
76
|
+
|
77
|
+
# Check if the entity is a person
|
78
|
+
#
|
79
|
+
# @return [Type] description of returned object
|
80
|
+
def person?
|
81
|
+
date_integer = @value[0, 2].to_i
|
82
|
+
return true if date_integer < 32
|
83
|
+
false
|
65
84
|
end
|
66
85
|
|
67
86
|
# Get the year of birth or registration
|