Class: SecID::CIK

Inherits:
Base
  • Object
show all
Defined in:
lib/sec_id/cik.rb

Overview

Note:

CIK identifiers have no check digit and validation is based solely on format.

Central Index Key (CIK) - SEC identifier for entities filing with the SEC. A 1-10 digit number that uniquely identifies entities in SEC systems.

Examples:

Validate a CIK

SecID::CIK.valid?('0001521365')  #=> true
SecID::CIK.valid?('1521365')     #=> true

Normalize a CIK to 10 digits

SecID::CIK.normalize('1521365')  #=> '0001521365'

See Also:

Constant Summary collapse

FULL_NAME =

Human-readable name of the standard.

'Central Index Key'
ID_LENGTH =

Valid length(s) of a normalized identifier.

(1..10)
EXAMPLE =

A representative valid identifier.

'0001521365'
VALID_CHARS_REGEX =

Pattern matching the identifier's permitted character set.

/\A[0-9]+\z/
ID_REGEX =

Regular expression for parsing CIK components.

/\A
  (?=\d{1,10}\z)(?<padding>0*)(?<identifier>[1-9]\d{0,9})
\z/x

Constants included from Generatable

Generatable::ALPHA, Generatable::ALPHANUMERIC, Generatable::DIGITS

Constants included from Validatable

Validatable::ERROR_MAP

Constants included from Normalizable

Normalizable::SEPARATORS

Instance Attribute Summary collapse

Attributes inherited from Base

#full_id, #identifier

Instance Method Summary collapse

Methods inherited from Base

#==, #as_json, example, full_name, has_check_digit?, #hash, id_length, length_specificity, length_values, short_name, #to_h

Methods included from Validatable

#errors, #valid?, #validate, #validate!

Methods included from Normalizable

#to_pretty_s, #to_str

Constructor Details

#initialize(cik) ⇒ CIK

Returns a new instance of CIK.

Parameters:

  • cik (String, Integer)

    the CIK to parse



36
37
38
39
40
# File 'lib/sec_id/cik.rb', line 36

def initialize(cik)
  cik_parts = parse(cik)
  @padding = cik_parts[:padding]
  @identifier = cik_parts[:identifier]
end

Instance Attribute Details

#paddingString? (readonly)

Returns the leading zeros in the CIK.

Returns:

  • (String, nil)

    the leading zeros in the CIK



33
34
35
# File 'lib/sec_id/cik.rb', line 33

def padding
  @padding
end

Instance Method Details

#normalize!self

Returns:

  • (self)

Raises:



51
52
53
54
55
# File 'lib/sec_id/cik.rb', line 51

def normalize!
  super
  @padding = @full_id[0, self.class::ID_LENGTH.max - @identifier.length]
  self
end

#normalizedString

Returns the normalized 10-digit CIK.

Returns:

  • (String)

    the normalized 10-digit CIK

Raises:



44
45
46
47
# File 'lib/sec_id/cik.rb', line 44

def normalized
  validate!
  @identifier.rjust(self.class::ID_LENGTH.max, '0')
end

#to_sString

Returns:

  • (String)


58
59
60
# File 'lib/sec_id/cik.rb', line 58

def to_s
  full_id
end