Class: ClassHDL::BlockFOREACH

Inherits:
BlockELSE show all
Defined in:
lib/tdl/class_hdl/hdl_foreach.rb

Instance Attribute Summary collapse

Attributes inherited from BlockIF

#cond, #opertor_chains, #slaver

Instance Method Summary collapse

Methods inherited from BlockIF

#initialize

Constructor Details

This class inherits a constructor from ClassHDL::BlockIF

Instance Attribute Details

#flagObject

Returns the value of attribute flag.



4
5
6
# File 'lib/tdl/class_hdl/hdl_foreach.rb', line 4

def flag
  @flag
end

Instance Method Details

#instance(as_type = :cond) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/tdl/class_hdl/hdl_foreach.rb', line 5

def instance(as_type= :cond)
   
    head_str = "foreach(#{cond.to_s}[#{flag}])begin"

    sub_str = []
    opertor_chains.each do |oc|
        unless oc.is_a? BlockIF
            unless oc.slaver
                sub_str.push "    #{oc.instance(as_type)};"
            end
        else 
            sub_str.push( oc.instance(as_type).gsub(/^./){ |m| "    #{m}"} )
        end
    end

    return "#{head_str}\n#{sub_str.join("\n")}\nend"

end