Class: RelatonBipm::Committee
- Inherits:
-
RelatonBib::LocalizedString
- Object
- RelatonBib::LocalizedString
- RelatonBipm::Committee
- Defined in:
- lib/relaton_bipm/committee.rb
Constant Summary collapse
- ACRONYMS =
YAML.load_file File.join(__dir__, "acronyms.yaml")
Instance Attribute Summary collapse
- #acronym ⇒ String readonly
- #content ⇒ RelatonBib::LocalizedString readonly
Instance Method Summary collapse
-
#initialize(acronym:, **args) ⇒ Committee
constructor
A new instance of Committee.
- #to_asciibib(prefix, count = 1) ⇒ String
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(acronym:, **args) ⇒ Committee
Returns a new instance of Committee.
16 17 18 19 20 21 22 23 24 |
# File 'lib/relaton_bipm/committee.rb', line 16 def initialize(acronym:, **args) unless ACRONYMS[acronym] Util.warn "Invalid acronym: `#{acronym}`. Allowed " \ "values: `#{ACRONYMS.map { |k, _v| k }.join '`, `'}`" end @acronym = acronym super(*localized_args(acronym, **args)) end |
Instance Attribute Details
#acronym ⇒ String (readonly)
6 7 8 |
# File 'lib/relaton_bipm/committee.rb', line 6 def acronym @acronym end |
#content ⇒ RelatonBib::LocalizedString (readonly)
9 10 11 |
# File 'lib/relaton_bipm/committee.rb', line 9 def content @content end |
Instance Method Details
#to_asciibib(prefix, count = 1) ⇒ String
34 35 36 37 38 39 40 |
# File 'lib/relaton_bipm/committee.rb', line 34 def to_asciibib(prefix, count = 1) pref = prefix.empty? ? prefix : "#{prefix}." pref += "committee" out = count > 1 ? "#{pref}::\n" : "" out += "#{pref}.acronym:: #{acronym}\n" out + super(pref) end |
#to_hash ⇒ Hash
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/relaton_bipm/committee.rb', line 43 def to_hash hash = { "acronym" => acronym } cnt = super case cnt when Array then hash["variants"] = cnt when Hash then hash.merge! cnt else hash["content"] = cnt end hash end |
#to_xml(builder) ⇒ Object
27 28 29 |
# File 'lib/relaton_bipm/committee.rb', line 27 def to_xml(builder) builder.committee(acronym: acronym) { |b| super b } end |