Class: SecID::CFI::Field
- Inherits:
-
Object
- Object
- SecID::CFI::Field
- Defined in:
- lib/sec_id/cfi/field.rb
Overview
A single decoded CFI position: the category, the group, or one attribute.
Carries its raw CFI letter (#code), semantic symbol (#name), ISO label
(#label), and — for attributes — the group meaning it answers
(#meaning). Defines a <name>? predicate for every symbol in its domain,
so category.equity? is answerable while an out-of-domain predicate such
as category.voting? raises NoMethodError.
Built by Classification; also usable on its own.
Instance Attribute Summary collapse
-
#code ⇒ String
readonly
The raw CFI letter (e.g. "E", "V").
-
#label ⇒ String
readonly
The authoritative ISO label.
-
#meaning ⇒ Symbol?
readonly
The group meaning for attribute fields, nil for category/group.
-
#name ⇒ Symbol
readonly
The semantic symbol (e.g. :equity, :voting).
Instance Method Summary collapse
- #as_json ⇒ Hash{Symbol => Object}
-
#initialize(code, name, label, domain, meaning: nil) ⇒ Field
constructor
A new instance of Field.
- #to_h ⇒ Hash{Symbol => Object}
-
#to_s ⇒ String
The ISO label.
Constructor Details
#initialize(code, name, label, domain, meaning: nil) ⇒ Field
Returns a new instance of Field.
31 32 33 34 35 36 37 38 |
# File 'lib/sec_id/cfi/field.rb', line 31 def initialize(code, name, label, domain, meaning: nil) @code = code @name = name @label = label @meaning = meaning domain.each { |symbol| define_singleton_method(:"#{symbol}?") { @name == symbol } } freeze end |
Instance Attribute Details
#code ⇒ String (readonly)
Returns the raw CFI letter (e.g. "E", "V").
15 16 17 |
# File 'lib/sec_id/cfi/field.rb', line 15 def code @code end |
#label ⇒ String (readonly)
Returns the authoritative ISO label.
21 22 23 |
# File 'lib/sec_id/cfi/field.rb', line 21 def label @label end |
#meaning ⇒ Symbol? (readonly)
Returns the group meaning for attribute fields, nil for category/group.
24 25 26 |
# File 'lib/sec_id/cfi/field.rb', line 24 def meaning @meaning end |
#name ⇒ Symbol (readonly)
Returns the semantic symbol (e.g. :equity, :voting).
18 19 20 |
# File 'lib/sec_id/cfi/field.rb', line 18 def name @name end |
Instance Method Details
#as_json ⇒ Hash{Symbol => Object}
51 52 53 |
# File 'lib/sec_id/cfi/field.rb', line 51 def as_json(*) to_h end |
#to_h ⇒ Hash{Symbol => Object}
46 47 48 |
# File 'lib/sec_id/cfi/field.rb', line 46 def to_h { code: code, name: name, label: label } end |
#to_s ⇒ String
Returns the ISO label.
41 42 43 |
# File 'lib/sec_id/cfi/field.rb', line 41 def to_s label end |