Class: Pubid::Export::IdentifierTypeResult
- Inherits:
-
Object
- Object
- Pubid::Export::IdentifierTypeResult
- Defined in:
- lib/pubid/export/result.rb
Overview
Immutable value object representing extracted metadata for one identifier type. Encapsulates all data needed by the website for a single doc type entry.
Instance Attribute Summary collapse
-
#abbr ⇒ Object
readonly
Returns the value of attribute abbr.
-
#examples ⇒ Object
readonly
Returns the value of attribute examples.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#short ⇒ Object
readonly
Returns the value of attribute short.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#typed_stages ⇒ Object
readonly
Returns the value of attribute typed_stages.
Instance Method Summary collapse
-
#initialize(key:, title:, short: nil, abbr: [], typed_stages: [], examples: []) ⇒ IdentifierTypeResult
constructor
A new instance of IdentifierTypeResult.
- #to_h ⇒ Object (also: #to_hash)
Constructor Details
#initialize(key:, title:, short: nil, abbr: [], typed_stages: [], examples: []) ⇒ IdentifierTypeResult
Returns a new instance of IdentifierTypeResult.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pubid/export/result.rb', line 10 def initialize(key:, title:, short: nil, abbr: [], typed_stages: [], examples: []) @key = key.to_s @title = title @short = short @abbr = Array(abbr).map(&:to_s) @typed_stages = typed_stages.map do |ts| TypedStageResult.from_typed_stage(ts) end @examples = examples freeze end |
Instance Attribute Details
#abbr ⇒ Object (readonly)
Returns the value of attribute abbr.
8 9 10 |
# File 'lib/pubid/export/result.rb', line 8 def abbr @abbr end |
#examples ⇒ Object (readonly)
Returns the value of attribute examples.
8 9 10 |
# File 'lib/pubid/export/result.rb', line 8 def examples @examples end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
8 9 10 |
# File 'lib/pubid/export/result.rb', line 8 def key @key end |
#short ⇒ Object (readonly)
Returns the value of attribute short.
8 9 10 |
# File 'lib/pubid/export/result.rb', line 8 def short @short end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
8 9 10 |
# File 'lib/pubid/export/result.rb', line 8 def title @title end |
#typed_stages ⇒ Object (readonly)
Returns the value of attribute typed_stages.
8 9 10 |
# File 'lib/pubid/export/result.rb', line 8 def typed_stages @typed_stages end |
Instance Method Details
#to_h ⇒ Object Also known as: to_hash
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/pubid/export/result.rb', line 23 def to_h { key: @key, title: @title, short: @short, abbr: @abbr, typed_stages: @typed_stages.map(&:to_h), examples: @examples, } end |