weird 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/weird.rb +10 -19
- data/lib/weird/version.rb +1 -1
- metadata +3 -3
data/lib/weird.rb
CHANGED
@@ -4,27 +4,18 @@ module Weird
|
|
4
4
|
FIRST_WEIGHTING = [3, 2, 7, 6, 5, 4, 3, 2]
|
5
5
|
SECOND_WEIGHTING = [7, 4, 3, 2, 5, 2, 7, 6]
|
6
6
|
def self.version_string
|
7
|
-
"Weird version #{Weird::VERSION}"
|
7
|
+
"Weird version: #{Weird::VERSION}"
|
8
8
|
end
|
9
9
|
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
# - If the remainder is not 0 then subtract this number from 11, giving the check digit (0 - 9
|
20
|
-
# are valid).
|
21
|
-
# - If the resulting check digit is 10, use a secondary set of weight factors and apply steps 2
|
22
|
-
# and 3 to the same input base number. From left to right the factors for an eight digit
|
23
|
-
# base number are: 7, 4, 3, 2, 5, 2, 7, 6.
|
24
|
-
# - Remember there is a leading zero for a seven digit base number. If the new check digit
|
25
|
-
# is again 10 then the IRD number is invalid (0 - 9 is valid).
|
26
|
-
# - Compare the calculated check digit with the check digit on the IRD number. If they
|
27
|
-
# match then the IRD number is valid.
|
10
|
+
# Performs validation on NZ IRD numbers.
|
11
|
+
# See http://www.ird.govt.nz/resources/c/5/c5a1198040c469449d4bbddaafba9fa8/payroll-spec-2011-v3.pdf for validation rules
|
12
|
+
#
|
13
|
+
# Example:
|
14
|
+
# >> Weird.valid_ird?("49091850")
|
15
|
+
# => true
|
16
|
+
#
|
17
|
+
# Arguments:
|
18
|
+
# ird_number: (String)
|
28
19
|
def self.valid_ird? input
|
29
20
|
is_integer(input) && valid_range(input) && check_digit_matches(input)
|
30
21
|
end
|
data/lib/weird/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weird
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-26 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70120853598360 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '2.7'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70120853598360
|
25
25
|
description: Checksum validation for New Zealand IRD numbers. See http://www.ird.govt.nz/how-to/irdnumbers/
|
26
26
|
for details of what an IRD is.
|
27
27
|
email:
|