class DataMetaPii::AttrSect

Attribute section with constants, references and a VO class optionally defined

Attributes

consts[R]
key[R]
refs[R]
voClass[R]

Public Class Methods

new(key) click to toggle source
# File lib/dataMetaPii.rb, line 220
def initialize(key)
    @key = key
    @refs = Hash.new(*[])
    @consts = Hash.new(*[])
    @voClass = nil
end

Public Instance Methods

+(val) click to toggle source

Add a new value to this section, depending on the incoming type

# File lib/dataMetaPii.rb, line 228
def +(val)
    case val
        when AlAttrVoClass
            raise RuntimeError, %<Attempt to redefine VO Class on "#{@key}"> if @voClass
            @voClass = val

        when AttrRef
            raise RuntimeError,
                  %<Reference to "#{val.key}" specified more than once on the attribute section "#{
                    @key}"> if @refs.has_key?(val.key.to_sym)

            @refs[val.key.to_sym] = val

        when AlAttrStr, AlAttrInt, AlAttrDec
            raise RuntimeError,
                  %<Constant "#{val.key}" specified more than once on "#{@key}"> if @consts.has_key?(val.key.to_sym)

            @consts[val.key.to_sym] = val
        else
            raise ArgumentError, %<Unsupported attribute type #{val.class} = #{val.inspect}>
    end
end
to_s() click to toggle source

String representation

# File lib/dataMetaPii.rb, line 252
def to_s
    %<#{self.class.name}{VO=#{@voClass}, Refs=#{@refs.inspect}, Const=#{@consts.inspect}}>
end