Class: RelatonBib::Edition
Instance Attribute Summary collapse
-
#content ⇒ String
readonly
Edition.
-
#number ⇒ String?
readonly
Number.
Instance Method Summary collapse
-
#initialize(content:, number: nil) ⇒ Edition
constructor
Initialize edition.
-
#to_asciibib(prefix = "") ⇒ String
Render edition as AsciiBib.
-
#to_hash ⇒ Hash
Return edition as hash.
-
#to_xml(builder) ⇒ Object
Render edition as XML.
Constructor Details
#initialize(content:, number: nil) ⇒ Edition
Initialize edition.
15 16 17 18 |
# File 'lib/relaton_bib/edition.rb', line 15 def initialize(content:, number: nil) @content = content.to_s @number = number&.to_s end |
Instance Attribute Details
#content ⇒ String (readonly)
Returns edition.
4 5 6 |
# File 'lib/relaton_bib/edition.rb', line 4 def content @content end |
#number ⇒ String? (readonly)
Returns number.
7 8 9 |
# File 'lib/relaton_bib/edition.rb', line 7 def number @number end |
Instance Method Details
#to_asciibib(prefix = "") ⇒ String
Render edition as AsciiBib.
48 49 50 51 52 53 |
# File 'lib/relaton_bib/edition.rb', line 48 def to_asciibib(prefix = "") pref = prefix.empty? ? "edition" : "#{prefix}.edition" out = "#{pref}.content:: #{content}\n" out += "#{pref}.number:: #{number}\n" if number out end |
#to_hash ⇒ Hash
Return edition as hash.
35 36 37 38 39 |
# File 'lib/relaton_bib/edition.rb', line 35 def to_hash hash = { "content" => content } hash["number"] = number if number hash end |
#to_xml(builder) ⇒ Object
Render edition as XML.
25 26 27 28 |
# File 'lib/relaton_bib/edition.rb', line 25 def to_xml(builder) node = builder.edition(content) node[:number] = number if number end |