Class: SFRP::Flat::Set
- Inherits:
-
Object
- Object
- SFRP::Flat::Set
- Defined in:
- lib/sfrp/flat/set.rb
Instance Method Summary collapse
- #<<(element) ⇒ Object
- #append_init_func_str(init_func_str) ⇒ Object
- #append_output_node_str(node_str) ⇒ Object
-
#initialize(&block) ⇒ Set
constructor
A new instance of Set.
- #node(str) ⇒ Object
- #tconst(str) ⇒ Object
- #to_poly ⇒ Object
Constructor Details
#initialize(&block) ⇒ Set
Returns a new instance of Set.
9 10 11 12 13 14 15 16 17 |
# File 'lib/sfrp/flat/set.rb', line 9 def initialize(&block) @funcs = [] @tconsts = [] @vconsts = [] @nodes = [] @output_node_strs = [] @init_func_strs = [] block.call(self) if block end |
Instance Method Details
#<<(element) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sfrp/flat/set.rb', line 37 def <<(element) case element when Function @funcs << element when TConst @tconsts << element when VConst @vconsts << element when Node @nodes << element else raise end end |
#append_init_func_str(init_func_str) ⇒ Object
33 34 35 |
# File 'lib/sfrp/flat/set.rb', line 33 def append_init_func_str(init_func_str) @init_func_strs << init_func_str end |
#append_output_node_str(node_str) ⇒ Object
29 30 31 |
# File 'lib/sfrp/flat/set.rb', line 29 def append_output_node_str(node_str) @output_node_strs << node_str end |
#node(str) ⇒ Object
56 57 58 |
# File 'lib/sfrp/flat/set.rb', line 56 def node(str) @nodes.find { |node| node.str == str } end |
#tconst(str) ⇒ Object
52 53 54 |
# File 'lib/sfrp/flat/set.rb', line 52 def tconst(str) @tconsts.find { |tconst| tconst.str == str } end |
#to_poly ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/sfrp/flat/set.rb', line 19 def to_poly Poly::Set.new do |dest_set| (@funcs + @tconsts + @vconsts + @nodes).each do |element| element.to_poly(self, dest_set) end @output_node_strs.each { |s| dest_set.append_output_node_str(s) } @init_func_strs.each { |s| dest_set.append_init_func_str(s) } end end |