Class: Pubid::Export::FlavorResult
- Inherits:
-
Object
- Object
- Pubid::Export::FlavorResult
- Defined in:
- lib/pubid/export/result.rb
Overview
Immutable value object for extracted flavor metadata.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#flavor ⇒ Object
readonly
Returns the value of attribute flavor.
-
#identifier_types ⇒ Object
readonly
Returns the value of attribute identifier_types.
-
#wrapper_types ⇒ Object
readonly
Returns the value of attribute wrapper_types.
Instance Method Summary collapse
-
#initialize(flavor:, identifier_types:, wrapper_types: [], attributes: []) ⇒ FlavorResult
constructor
A new instance of FlavorResult.
- #to_h ⇒ Object (also: #to_hash)
Constructor Details
#initialize(flavor:, identifier_types:, wrapper_types: [], attributes: []) ⇒ FlavorResult
Returns a new instance of FlavorResult.
74 75 76 77 78 79 80 81 |
# File 'lib/pubid/export/result.rb', line 74 def initialize(flavor:, identifier_types:, wrapper_types: [], attributes: []) @flavor = flavor.to_s @identifier_types = identifier_types @wrapper_types = wrapper_types @attributes = attributes freeze end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
72 73 74 |
# File 'lib/pubid/export/result.rb', line 72 def attributes @attributes end |
#flavor ⇒ Object (readonly)
Returns the value of attribute flavor.
72 73 74 |
# File 'lib/pubid/export/result.rb', line 72 def flavor @flavor end |
#identifier_types ⇒ Object (readonly)
Returns the value of attribute identifier_types.
72 73 74 |
# File 'lib/pubid/export/result.rb', line 72 def identifier_types @identifier_types end |
#wrapper_types ⇒ Object (readonly)
Returns the value of attribute wrapper_types.
72 73 74 |
# File 'lib/pubid/export/result.rb', line 72 def wrapper_types @wrapper_types end |
Instance Method Details
#to_h ⇒ Object Also known as: to_hash
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/pubid/export/result.rb', line 83 def to_h h = { identifier_types: @identifier_types.map(&:to_h), attributes: @attributes, } unless @wrapper_types.empty? h[:wrapper_types] = @wrapper_types.map(&:to_h) end h end |