za_id_number 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ed3ce4b45b45da798697e7c5f48873752f53b6c12fc07ec985805d5acfe1190
4
- data.tar.gz: 7e14ac75dc6ab6a710be4d3dc9a261a066515d1ac53522fe4a2b2d4c510eeed8
3
+ metadata.gz: 1091207c4bf7fe86f9dd8eff09d907439d0c77d13596ce394145b958c487ca65
4
+ data.tar.gz: '08fbe6e7a50f19a8a3d395b66f2e49e1883728387d47c52cf8ff8da4fdaba4fc'
5
5
  SHA512:
6
- metadata.gz: 327d332579085ea13569812f310e577f280677726635e2df2493e545c4123aea8ba5b59408fc7ed0c40b97bcc9a6c3842a822c516fd352b5faaf0acb2bd8bf55
7
- data.tar.gz: f7706ab08495208b569734ad6910ae90e4abbc82255fec79b32c202f865d88f6d7fd2a12c1e0843745bc86ea6e2db89bd4a69f6ace55038c34f2b7412645b7e1
6
+ metadata.gz: 650958c1b3305ad083b7b9ff0da547be34c292777c93635799e7bbdc04751fd74cd719761707832e4ea6d0d1d133dd5f2b887da9d21c5f201e8d6afc6b232d4c
7
+ data.tar.gz: d226d05b02865243ae604849da00669224b75984cd623947e54c97482fe0318157a490d0b65754e92dd49abdfbc69dee28239bfe01e0134526e262f903dfe672
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 2.5.7
1
+ ruby 2.7.6
data/CHANGES ADDED
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project tries really hard to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ Nothing
11
+
12
+ ## [2.1.0] - 2022-05-31
13
+
14
+ ### Added
15
+
16
+ - `to_s` for easier string interpolation
17
+ - Add equality operator `==` and `eql?` method
18
+ - Add `hash` method
19
+ - Make id number instances immutable
@@ -1,5 +1,5 @@
1
1
  class ZAIDNumber
2
2
  class Version
3
- VERSION = '2.0.0'
3
+ VERSION = '2.1.0'
4
4
  end
5
5
  end
data/lib/za_id_number.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'za_id_number/version'
2
4
  require 'luhn'
3
5
  require 'date'
@@ -11,9 +13,10 @@ class ZAIDNumber
11
13
  PERMANENT_RESIDENT = 1
12
14
 
13
15
  attr_reader :id_number
16
+ alias to_s id_number
14
17
 
15
18
  def initialize(id_num)
16
- @id_number = id_num.to_s
19
+ @id_number = id_num.to_s.freeze
17
20
  end
18
21
 
19
22
  def valid?
@@ -73,4 +76,15 @@ class ZAIDNumber
73
76
  def permanent_resident?
74
77
  !za_citizen?
75
78
  end
79
+
80
+ def ==(other)
81
+ return false unless other.is_a?(ZAIDNumber)
82
+
83
+ return id_number == other.id_number
84
+ end
85
+ alias eql? ==
86
+
87
+ def hash
88
+ id_number.hash
89
+ end
76
90
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: za_id_number
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Fortuna
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-12 00:00:00.000000000 Z
11
+ date: 2022-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,6 +112,7 @@ files:
112
112
  - ".rspec"
113
113
  - ".tool-versions"
114
114
  - ".travis.yml"
115
+ - CHANGES
115
116
  - CODE_OF_CONDUCT.md
116
117
  - Gemfile
117
118
  - LICENSE.txt
@@ -127,7 +128,7 @@ homepage: http://www.zero-one.io
127
128
  licenses:
128
129
  - MIT
129
130
  metadata: {}
130
- post_install_message:
131
+ post_install_message:
131
132
  rdoc_options: []
132
133
  require_paths:
133
134
  - lib
@@ -142,8 +143,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
143
  - !ruby/object:Gem::Version
143
144
  version: '0'
144
145
  requirements: []
145
- rubygems_version: 3.2.14
146
- signing_key:
146
+ rubygems_version: 3.1.6
147
+ signing_key:
147
148
  specification_version: 4
148
149
  summary: A small library for parsing South African ID numbers
149
150
  test_files: []