Class: Config::ComplexFreqencies

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

Constant Summary collapse

@@subitemregex =
/\A([\w\(\)]+)\s*->\s*(\w+)\s*,\s*(\w+)\s*\Z/

Instance Attribute Summary

Attributes inherited from ComplexItem

#name, #overwrite, #value

Attributes inherited from Item

#priority

Instance Method Summary collapse

Methods inherited from ComplexItem

getRegex, #merge

Methods inherited from Item

#merge, #name, #value

Constructor Details

#initialize(_str, _regex) ⇒ ComplexFreqencies

Returns a new instance of ComplexFreqencies.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/module_config/items/complexfreqencies.rb', line 24

def initialize(_str, _regex)
    super(_str, _regex)
    
    tmp = @value
    @value = []
    tmp.each do |item| 
        item.strip!    
        if item =~ @@subitemregex
            item = Hash.new
            item["signalname"]  = $1
            item["freqency"]    = $2
            item["clockname"]   = $3
            @value.push(item)
        else
            raise ConfigWrongFormatException.new(self.class), "Configuration subitem <#{item}> of item <#{name}> has wrong format."
        end
        
    end
end

Instance Method Details

#each(&_block) ⇒ Object



44
45
46
47
48
# File 'lib/module_config/items/complexfreqencies.rb', line 44

def each(&_block)
    @value.each do |subitem|
        _block.call(subitem["signalname"], subitem["freqency"], subitem["clockname"])
    end
end


50
51
52
53
54
# File 'lib/module_config/items/complexfreqencies.rb', line 50

def print
    puts "    #{@name} = {      ##{self.class.to_s}"
    @value.each { |v| puts "        #{v["signalname"]} -> #{v["freqency"]}, #{v["clockname"]};" }
    puts "    }"
end