weird 0.0.2 → 0.0.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.
Files changed (3) hide show
  1. data/lib/weird.rb +10 -19
  2. data/lib/weird/version.rb +1 -1
  3. metadata +3 -3
@@ -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
- # Check digit validation
11
- # The following steps are to be performed:
12
- # - Valid range >10,000,000 & <150,000,000 (This will ensure invalid numbers that will not
13
- # be issued for another 10 years cannot be used in error)
14
- # - To each of the base number’s eight digits a weight factor is assigned. From left to right
15
- # these are: 3, 2, 7, 6, 5, 4, 3, 2.
16
- # - Where the base number is seven digits remember there is a leading zero.
17
- # - Sum together the products of the weight factors and their associated digits.
18
- # - Divide the sum by 11. If the remainder is 0 then the check digit is 0.
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
@@ -1,3 +1,3 @@
1
1
  module Weird
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
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.2
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: &70231797548840 !ruby/object:Gem::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: *70231797548840
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: