class RelatonIho::IHOGroup
Attributes
abbreviation[R]
@return [String]
name[R]
@return [String, nil]
subgroup[R]
@return [RelatonIho::Committee, RelatonIho::Workgroup
,
RelatonIho::Commission, nil]
Public Class Methods
expand(abbr)
click to toggle source
@param abbr [String] @return [RelatonIho::EditorialGroup]
# File lib/relaton_iho/iho_group.rb, line 26 def expand(abbr) struct = YAML.load_file File.expand_path("eg.yml", __dir__) from_abbr abbr.upcase, struct end
new(abbreviation, name = nil, subgroup = nil)
click to toggle source
@param abbreviation [String] @param name [String, nil] @param subgroup [RelatonIho::Committee, RelatonIho::Workgroup
,
RelatonIho::Commission, nil]
# File lib/relaton_iho/iho_group.rb, line 17 def initialize(abbreviation, name = nil, subgroup = nil) @abbreviation = abbreviation @name = name @subgroup = subgroup end
Private Class Methods
expand_from_abbr(abbr, struct)
click to toggle source
@param abbr [String] @param struct [Hash] @return [RelatonIho::Committee, RelatonIho::Commission
,
RelatonIho::Workgroup]
# File lib/relaton_iho/iho_group.rb, line 50 def expand_from_abbr(abbr, struct) struct.each do |k, g| wg = from_abbr abbr, g["subgroup"] return klass(g["class"]).new k, g["name"], wg if wg end nil end
from_abbr(abbr, struct)
click to toggle source
@param abbr [String] @param struct [Hash] @return [RelatonIho::Committee, RelatonIho::Commission
,
RelatonIho::Workgroup]
# File lib/relaton_iho/iho_group.rb, line 37 def from_abbr(abbr, struct) return unless struct gr = struct.detect { |k, v| k == abbr || v["previously"] == abbr } return klass(gr[1]["class"]).new abbr, gr[1]["name"] if gr expand_from_abbr abbr, struct end
klass(name)
click to toggle source
# File lib/relaton_iho/iho_group.rb, line 58 def klass(name) Object.const_get "RelatonIho::" + name end
Public Instance Methods
to_asciibib(prefix, count = 1)
click to toggle source
@param prefix [String] @param count [Integer] @return [Strin]
# File lib/relaton_iho/iho_group.rb, line 81 def to_asciibib(prefix, count = 1) out = count > 1 ? "#{prefix}::\n" : "" out += "#{prefix}.abbreviation:: #{abbreviation}\n" out += "#{prefix}.name:: #{name}\n" if name out += subgroup.to_asciibib prefix if subgroup out end
to_hash()
click to toggle source
@return [Hash]
# File lib/relaton_iho/iho_group.rb, line 71 def to_hash hash = { "abbreviation" => abbreviation } hash["name"] = name if name hash.merge! subgroup.to_hash if subgroup hash end
to_xml(builder)
click to toggle source
@param builder [Nokogiri::XML::Builder]
# File lib/relaton_iho/iho_group.rb, line 64 def to_xml(builder) builder.name name if name builder.abbreviation abbreviation subgroup&.to_xml builder end