Class: RelatonIsoBib::Ics
- Inherits:
-
Isoics::ICS
- Object
- Isoics::ICS
- RelatonIsoBib::Ics
- Defined in:
- lib/relaton_iso_bib/ics.rb
Overview
Iso ICS classificator.
Instance Method Summary collapse
-
#initialize(code = nil, field: nil, group: nil, subgroup: nil) ⇒ Ics
constructor
A new instance of Ics.
- #to_asciibib(prefix = "", count = 1) ⇒ String
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(code = nil, field: nil, group: nil, subgroup: nil) ⇒ Ics
Returns a new instance of Ics.
8 9 10 11 12 13 14 15 16 |
# File 'lib/relaton_iso_bib/ics.rb', line 8 def initialize(code = nil, field: nil, group: nil, subgroup: nil) unless code || field raise ArgumentError, "wrong arguments (should be string or { fieldcode: [String] }" end field, group, subgroup = code.split "." if code super fieldcode: field, groupcode: group, subgroupcode: subgroup end |
Instance Method Details
#to_asciibib(prefix = "", count = 1) ⇒ String
37 38 39 40 41 42 43 44 |
# File 'lib/relaton_iso_bib/ics.rb', line 37 def to_asciibib(prefix = "", count = 1) pref = prefix.empty? ? prefix : prefix + "." pref += "ics" out = count > 1 ? "#{pref}::\n" : "" out += "#{pref}.code:: #{code}\n" out += "#{pref}.description:: #{description}\n" out end |
#to_hash ⇒ Hash
27 28 29 30 31 32 |
# File 'lib/relaton_iso_bib/ics.rb', line 27 def to_hash hash = {} hash["code"] = code if code hash["text"] = description if description hash end |
#to_xml(builder) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/relaton_iso_bib/ics.rb', line 19 def to_xml(builder) builder.ics do builder.code code builder.text_ description end end |