Sha256: b9a6e95274903bdaee32a4cccb642fb22342c8f58cda04056c6117f1badda3a3

Contents?: true

Size: 1.04 KB

Versions: 73

Compression:

Stored size: 1.04 KB

Contents

module RelatonBipm
  class WorkGroup
    # @return [String]
    attr_reader :content

    # @return [String, nil]
    attr_reader :acronym

    # @param content [String]
    # @param acronym [String, nil]
    def initialize(content:, acronym: nil)
      @content = content
      @acronym = acronym
    end

    # @param builder [Nokogiri::XML::Builder]
    def to_xml(builder)
      xml = builder.workgroup content
      xml[:acronym] = acronym if acronym
    end

    # @param prefix [String]
    # @param count [Integer]
    # @return [String]
    def to_asciibib(prefix, count = 1)
      pref = prefix.empty? ? prefix : prefix + "."
      pref += "workgroup"
      if acronym
        out = count > 1 ? "#{pref}::\n" : ""
        out += "#{pref}.acronym:: #{acronym}\n"
        out + "#{pref}.content:: #{content}\n"
      else "#{pref}:: #{content}\n"
      end
    end

    # @return [Hash, String]
    def to_hash
      if acronym
        hash = { "content" => content }
        hash["acronym"] = acronym
        hash
      else content
      end
    end
  end
end

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
relaton-bipm-1.20.3 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.20.2 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.19.4 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.20.1 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.19.3 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.20.0.v1.19.3.1 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.20.0 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.19.2 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.19.1 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.19.0 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.18.2 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.18.1 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.18.0 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.17.1 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.17.0 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.16.6 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.16.5 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.16.4 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.16.3 lib/relaton_bipm/workgroup.rb
relaton-bipm-1.16.2 lib/relaton_bipm/workgroup.rb