diff --git a/lib/sec_id/cusip.rb b/lib/sec_id/cusip.rb index 2631ebb..6fad6f7 100644 --- a/lib/sec_id/cusip.rb +++ b/lib/sec_id/cusip.rb @@ -35,6 +35,11 @@ def to_isin(country_code) isin end + # CUSIP International Numbering System + def cins? + !cusip6[0].match?(/[0-9]/) + end + private # https://en.wikipedia.org/wiki/Luhn_algorithm diff --git a/spec/sec_id/cusip_spec.rb b/spec/sec_id/cusip_spec.rb index 9910f03..7a651a3 100644 --- a/spec/sec_id/cusip_spec.rb +++ b/spec/sec_id/cusip_spec.rb @@ -89,6 +89,24 @@ end end + describe '#cins?' do + context 'when a CINS' do + let(:cusip_number) { 'G0052B105' } + + it 'returns true' do + expect(cusip.cins?).to be(true) + end + end + + context 'when not a CINS' do + let(:cusip_number) { '084664BL4' } + + it 'returns false' do + expect(cusip.cins?).to be(false) + end + end + end + describe '.restore!' do context 'when CUSIP is incorrect' do it 'raises an error' do