Sha256: c4d5ae39ae9dcf695e5f21b0129cea804d45394053bdbf1c8290d4c0dd0b716d

Contents?: true

Size: 1.2 KB

Versions: 16

Compression:

Stored size: 1.2 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)
        warn "[relaton-ieee] WARNING: 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

16 entries across 16 versions & 1 rubygems

Version Path
relaton-ieee-1.16.0 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.14.8 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.14.7 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.14.6 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.14.5 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.14.4 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.14.3 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.14.2 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.14.1 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.14.0 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.13.1 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.13.0 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.12.8 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.12.7 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.12.6 lib/relaton_ieee/balloting_group.rb
relaton-ieee-1.12.5 lib/relaton_ieee/balloting_group.rb