Class: RelatonBipm::Committee

Inherits:
RelatonBib::LocalizedString
  • Object
show all
Defined in:
lib/relaton_bipm/committee.rb

Constant Summary collapse

ACRONYMS =
YAML.load_file File.join(__dir__, "acronyms.yaml")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(acronym:, **args) ⇒ Committee

Returns a new instance of Committee.

Parameters:

  • acronym (String)
  • args (Hash)

Options Hash (**args):

  • :content (RelatonBib::LocalisedString, String, nil)
  • :language (String, nil)
  • :script (String, nil)


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

#acronymString (readonly)

Returns:

  • (String)


6
7
8
# File 'lib/relaton_bipm/committee.rb', line 6

def acronym
  @acronym
end

#contentRelatonBib::LocalizedString (readonly)

Returns:

  • (RelatonBib::LocalizedString)


9
10
11
# File 'lib/relaton_bipm/committee.rb', line 9

def content
  @content
end

Instance Method Details

#to_asciibib(prefix, count = 1) ⇒ String

Parameters:

  • prefix (String)
  • count (Integer) (defaults to: 1)

Returns:

  • (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_hashHash

Returns:

  • (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

Parameters:

  • builder (Nokogiri::XML::Builder)


27
28
29
# File 'lib/relaton_bipm/committee.rb', line 27

def to_xml(builder)
  builder.committee(acronym: acronym) { |b| super b }
end