Class: DataMetaPii::AttrSect
- Inherits:
-
Object
- Object
- DataMetaPii::AttrSect
- Defined in:
- lib/dataMetaPii.rb
Overview
Attribute section with constants, references and a VO class optionally defined
Instance Attribute Summary collapse
-
#consts ⇒ Object
readonly
Returns the value of attribute consts.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#refs ⇒ Object
readonly
Returns the value of attribute refs.
-
#voClass ⇒ Object
readonly
Returns the value of attribute voClass.
Instance Method Summary collapse
-
#+(val) ⇒ Object
Add a new value to this section, depending on the incoming type.
-
#initialize(key) ⇒ AttrSect
constructor
A new instance of AttrSect.
-
#to_s ⇒ Object
String representation.
Constructor Details
#initialize(key) ⇒ AttrSect
Returns a new instance of AttrSect.
220 221 222 223 224 225 |
# File 'lib/dataMetaPii.rb', line 220 def initialize(key) @key = key @refs = Hash.new(*[]) @consts = Hash.new(*[]) @voClass = nil end |
Instance Attribute Details
#consts ⇒ Object (readonly)
Returns the value of attribute consts.
219 220 221 |
# File 'lib/dataMetaPii.rb', line 219 def consts @consts end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
219 220 221 |
# File 'lib/dataMetaPii.rb', line 219 def key @key end |
#refs ⇒ Object (readonly)
Returns the value of attribute refs.
219 220 221 |
# File 'lib/dataMetaPii.rb', line 219 def refs @refs end |
#voClass ⇒ Object (readonly)
Returns the value of attribute voClass.
219 220 221 |
# File 'lib/dataMetaPii.rb', line 219 def voClass @voClass end |
Instance Method Details
#+(val) ⇒ Object
Add a new value to this section, depending on the incoming type
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# 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 ⇒ Object
String representation
252 253 254 |
# File 'lib/dataMetaPii.rb', line 252 def to_s %<#{self.class.name}{VO=#{@voClass}, Refs=#{@refs.inspect}, Const=#{@consts.inspect}}> end |