Class: SecID::WKN
Overview
Wertpapierkennnummer (WKN) - a 6-character alphanumeric code used to identify securities in Germany.
Format: 6 alphanumeric characters (excluding I and O) Note: WKN excludes letters I and O to avoid confusion with 1 and 0.
Constant Summary collapse
- FULL_NAME =
Human-readable name of the standard.
'Wertpapierkennnummer'- ID_LENGTH =
Valid length(s) of a normalized identifier.
6- EXAMPLE =
A representative valid identifier.
'514000'- VALID_CHARS_REGEX =
Pattern matching the identifier's permitted character set.
/\A[0-9A-HJ-NP-Z]+\z/- ID_REGEX =
Regular expression for parsing WKN components. Excludes letters I and O to avoid confusion with 1 and 0.
/\A (?<identifier>[0-9A-HJ-NP-Z]{6}) \z/x- GENERATE_CHARSET =
Characters valid in a WKN (alphanumeric excluding I and O).
ALPHANUMERIC.grep(VALID_CHARS_REGEX).freeze
Constants included from Generatable
Generatable::ALPHA, Generatable::ALPHANUMERIC, Generatable::DIGITS
Constants included from Validatable
Constants included from Normalizable
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(wkn) ⇒ WKN
constructor
A new instance of WKN.
-
#to_isin(country_code = 'DE') ⇒ ISIN
A new ISIN instance with calculated check digit.
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
#normalize!, #normalized, #to_pretty_s, #to_s, #to_str
Constructor Details
#initialize(wkn) ⇒ WKN
Returns a new instance of WKN.
35 36 37 38 |
# File 'lib/sec_id/wkn.rb', line 35 def initialize(wkn) wkn_parts = parse(wkn) @identifier = wkn_parts[:identifier] end |
Instance Method Details
#to_isin(country_code = 'DE') ⇒ ISIN
Returns a new ISIN instance with calculated check digit.
44 45 46 47 48 49 |
# File 'lib/sec_id/wkn.rb', line 44 def to_isin(country_code = 'DE') raise InvalidFormatError, "'#{country_code}' is not a valid WKN country code!" unless country_code == 'DE' raise InvalidFormatError, "WKN '#{full_id}' is invalid!" unless valid_format? ISIN.new("#{country_code}000#{identifier}").restore! end |