Sha256: 7248eb202440997e9b5f90fca2d5c80fb795a87323f278591c0b13c8242fce12

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

module RelatonIeee
  class BallotingGroup
    TYPES = %w[individual entity].freeze

    # @return [String]
    attr_reader :type, :content

    #
    # Initialize balloting group
    #
    # @param [String] type type
    # @param [String] content content
    #
    def initialize(type:, content:)
      unless TYPES.include?(type)
        Util.warn "type of Balloting group must be one of `#{TYPES.join('`, `')}`"
      end

      @type = type
      @content = content
    end

    #
    # Render balloting group to XML
    #
    # @param [Nokogiri::XML::Builder] builder XML builder
    #
    def to_xml(builder)
      builder.send :"balloting-group", content, type: type
    end

    #
    # Render balloting group to Hash
    #
    # @return [Hash] balloting group as Hash
    #
    def to_hash
      { "type" => type, "content" => content }
    end

    #
    # Render balloting group to AsciiBib
    #
    # @param [String] prefix Prefix
    #
    # @return [String] AsciiBib
    #
    def to_asciibib(prefix = "")
      pref = prefix.empty? ? prefix : "#{prefix}."
      pref += "balloting-group"
      out = "#{pref}.type:: #{type}\n"
      out += "#{pref}.content:: #{content}\n"
      out
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
relaton-ieee-1.20.0 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.19.3 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.19.2 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.19.1 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.19.0 lib/relaton_ieee/balloting_group.rb