Class: Metacrunch::Mab2::Document::Controlfield
- Inherits:
-
Object
- Object
- Metacrunch::Mab2::Document::Controlfield
- Defined in:
- lib/metacrunch/mab2/document/controlfield.rb
Instance Attribute Summary collapse
-
#tag ⇒ Object
Returns the value of attribute tag.
Instance Method Summary collapse
-
#at(index) ⇒ Array<String>
Value at given index.
-
#initialize(tag = nil, values = []) ⇒ Controlfield
constructor
A new instance of Controlfield.
-
#to_xml(builder) ⇒ Object
—————————————————————————— Serialization ——————————————————————————.
- #values ⇒ Array<String>
-
#values=(values) ⇒ Object
Setter for the control field values.
Constructor Details
#initialize(tag = nil, values = []) ⇒ Controlfield
Returns a new instance of Controlfield.
8 9 10 11 |
# File 'lib/metacrunch/mab2/document/controlfield.rb', line 8 def initialize(tag = nil, values = []) self.tag = tag self.values = values end |
Instance Attribute Details
#tag ⇒ Object
Returns the value of attribute tag.
6 7 8 |
# File 'lib/metacrunch/mab2/document/controlfield.rb', line 6 def tag @tag end |
Instance Method Details
#at(index) ⇒ Array<String>
Returns value at given index.
54 55 56 |
# File 'lib/metacrunch/mab2/document/controlfield.rb', line 54 def at(index) @values.at(index) end |
#to_xml(builder) ⇒ Object
Serialization
62 63 64 |
# File 'lib/metacrunch/mab2/document/controlfield.rb', line 62 def to_xml(builder) builder.controlfield(values2string, tag: tag) end |
#values ⇒ Array<String>
46 47 48 |
# File 'lib/metacrunch/mab2/document/controlfield.rb', line 46 def values @values end |
#values=(values) ⇒ Object
Setter for the control field values. Values can be given as String or as an Array.
33 34 35 36 37 38 39 40 41 |
# File 'lib/metacrunch/mab2/document/controlfield.rb', line 33 def values=(values) @values = case values when String then string2values(values) when Array then array2values(values) when nil then [] else raise ArgumentError, "expecting a String or Array, but got #{values}" end end |