Class: Config::ComplexPackage

Inherits:
ComplexItem show all
Defined in:
lib/module_config/items/complexpackage.rb

Constant Summary collapse

@@subitemregex =
/\A.+\Z/

Instance Attribute Summary

Attributes inherited from ComplexItem

#name, #overwrite, #value

Attributes inherited from Item

#priority

Instance Method Summary collapse

Methods inherited from ComplexItem

#each, getRegex, #merge

Methods inherited from Item

#merge, #name, #value

Constructor Details

#initialize(_str, _regex) ⇒ ComplexPackage

Returns a new instance of ComplexPackage.



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/module_config/items/complexpackage.rb', line 25

def initialize(_str, _regex)
    super(_str, _regex)

    tmp = @value
    @value = []
    
    tmp.each do |item|
        item.strip!
        raise ConfigWrongFormatException.new(self.class), "Configuration subitem \n -----\n #{item} \n -----\n of item <#{name}> has wrong format." unless item =~ @@subitemregex
        @value.push(item.split(/,\s/))
    end
end

Instance Method Details



38
39
40
41
42
# File 'lib/module_config/items/complexpackage.rb', line 38

def print
    puts "    #{@name} = {      ##{self.class.to_s}"
    @value.each { |v| puts "        #{v.join(", ")};" }
    puts "    }"
end