Class: RelatonBib::WorkGroup
Instance Attribute Summary collapse
- #identifier ⇒ String? readonly
- #name ⇒ String readonly
- #number ⇒ Integer? readonly
- #prefix ⇒ String? readonly
- #type ⇒ String? readonly
Instance Method Summary collapse
-
#initialize(name:, identifier: nil, prefix: nil, number: nil, type: nil) ⇒ WorkGroup
constructor
A new instance of WorkGroup.
- #to_asciibib(prfx = "", count = 1) ⇒ String
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(name:, identifier: nil, prefix: nil, number: nil, type: nil) ⇒ WorkGroup
Returns a new instance of WorkGroup.
17 18 19 20 21 22 23 |
# File 'lib/relaton_bib/workgroup.rb', line 17 def initialize(name:, identifier: nil, prefix: nil, number: nil, type: nil) @identifier = identifier @prefix = prefix @name = name @number = number @type = type end |
Instance Attribute Details
#identifier ⇒ String? (readonly)
10 11 12 |
# File 'lib/relaton_bib/workgroup.rb', line 10 def identifier @identifier end |
#name ⇒ String (readonly)
4 5 6 |
# File 'lib/relaton_bib/workgroup.rb', line 4 def name @name end |
#number ⇒ Integer? (readonly)
7 8 9 |
# File 'lib/relaton_bib/workgroup.rb', line 7 def number @number end |
#prefix ⇒ String? (readonly)
10 11 12 |
# File 'lib/relaton_bib/workgroup.rb', line 10 def prefix @prefix end |
#type ⇒ String? (readonly)
10 11 12 |
# File 'lib/relaton_bib/workgroup.rb', line 10 def type @type end |
Instance Method Details
#to_asciibib(prfx = "", count = 1) ⇒ String
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/relaton_bib/workgroup.rb', line 47 def to_asciibib(prfx = "", count = 1) # rubocop:disable Metrics/CyclomaticComplexity pref = prfx.empty? ? prfx : "#{prfx}." out = count > 1 ? "#{pref}::\n" : "" out += "#{pref}name:: #{name}\n" out += "#{pref}number:: #{number}\n" if number out += "#{pref}type:: #{type}\n" if type out += "#{pref}identifier:: #{identifier}\n" if identifier out += "#{pref}prefix:: #{prefix}\n" if prefix out end |
#to_hash ⇒ Hash
35 36 37 38 39 40 41 42 |
# File 'lib/relaton_bib/workgroup.rb', line 35 def to_hash hash = { "name" => name } hash["number"] = number if number hash["type"] = type if type hash["identifier"] = identifier if identifier hash["prefix"] = prefix if prefix hash end |
#to_xml(builder) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/relaton_bib/workgroup.rb', line 26 def to_xml(builder) # rubocop:disable Metrics/AbcSize builder.text name builder.parent[:number] = number if number builder.parent[:type] = type if type builder.parent[:identifier] = identifier if identifier builder.parent[:prefix] = prefix if prefix end |