Class: RelatonBib::Classification
- Defined in:
- lib/relaton_bib/classification.rb
Instance Attribute Summary collapse
- #type ⇒ String, NilClass readonly
- #value ⇒ String readonly
Instance Method Summary collapse
-
#initialize(type: nil, value:) ⇒ Classification
constructor
A new instance of Classification.
- #to_asciibib(prefix = "", count = 1) ⇒ String
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(type: nil, value:) ⇒ Classification
Returns a new instance of Classification.
11 12 13 14 |
# File 'lib/relaton_bib/classification.rb', line 11 def initialize(type: nil, value:) @type = type @value = value end |
Instance Attribute Details
#type ⇒ String, NilClass (readonly)
4 5 6 |
# File 'lib/relaton_bib/classification.rb', line 4 def type @type end |
#value ⇒ String (readonly)
7 8 9 |
# File 'lib/relaton_bib/classification.rb', line 7 def value @value end |
Instance Method Details
#to_asciibib(prefix = "", count = 1) ⇒ String
32 33 34 35 36 37 38 |
# File 'lib/relaton_bib/classification.rb', line 32 def to_asciibib(prefix = "", count = 1) pref = prefix.empty? ? "classification" : prefix + ".classification" out = count > 1 ? "#{pref}::\n" : "" out += "#{pref}.type:: #{type}\n" if type out += "#{pref}.value:: #{value}\n" out end |
#to_hash ⇒ Hash
23 24 25 26 27 |
# File 'lib/relaton_bib/classification.rb', line 23 def to_hash hash = { "value" => value } hash["type"] = type if type hash end |
#to_xml(builder) ⇒ Object
17 18 19 20 |
# File 'lib/relaton_bib/classification.rb', line 17 def to_xml(builder) xml = builder.classification value xml[:type] = type if type end |