Class: RelatonBib::DocumentType
- Defined in:
- lib/relaton_bib/document_type.rb
Instance Attribute Summary collapse
-
#abbreviation ⇒ Object
readonly
Returns the value of attribute abbreviation.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type:, abbreviation: nil) ⇒ DocumentType
constructor
Initialize a DocumentType.
-
#to_asciibib(prefix = "") ⇒ String
Asciibib representation of the document type.
-
#to_hash ⇒ Hash
Hash representation of the document type.
-
#to_xml(builder) ⇒ Object
Build XML representation of the document type.
Constructor Details
#initialize(type:, abbreviation: nil) ⇒ DocumentType
Initialize a DocumentType.
11 12 13 14 |
# File 'lib/relaton_bib/document_type.rb', line 11 def initialize(type:, abbreviation: nil) @type = type @abbreviation = abbreviation end |
Instance Attribute Details
#abbreviation ⇒ Object (readonly)
Returns the value of attribute abbreviation.
3 4 5 |
# File 'lib/relaton_bib/document_type.rb', line 3 def abbreviation @abbreviation end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/relaton_bib/document_type.rb', line 3 def type @type end |
Instance Method Details
#to_asciibib(prefix = "") ⇒ String
Asciibib representation of the document type.
44 45 46 47 48 49 50 |
# File 'lib/relaton_bib/document_type.rb', line 44 def to_asciibib(prefix = "") pref = prefix.empty? ? prefix : "#{prefix}." pref += "doctype." out = "#{pref}type:: #{@type}\n" out += "#{pref}abbreviation:: #{@abbreviation}\n" if @abbreviation out end |
#to_hash ⇒ Hash
Hash representation of the document type.
31 32 33 34 35 |
# File 'lib/relaton_bib/document_type.rb', line 31 def to_hash hash = { "type" => @type } hash["abbreviation"] = @abbreviation if @abbreviation hash end |
#to_xml(builder) ⇒ Object
Build XML representation of the document type.
21 22 23 24 |
# File 'lib/relaton_bib/document_type.rb', line 21 def to_xml(builder) xml = builder.doctype @type xml[:abbreviation] = @abbreviation if @abbreviation end |