Module: Journeyviz::NodeGroup
Instance Method Summary collapse
- #block(name, &definition) ⇒ Object
- #blocks(include_children: false) ⇒ Object
- #find_screen(qualifier) ⇒ Object
- #inputs ⇒ Object
- #outputs ⇒ Object
- #screen(name) {|screen| ... } ⇒ Object
- #screens ⇒ Object
Instance Method Details
#block(name, &definition) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/journeyviz/node_group.rb', line 9 def block(name, &definition) block = Block.new(name, self) @blocks ||= [] if @blocks.any? { |defined_block| block.name == defined_block.name } raise DuplicatedDefinition, "Duplicated block name: #{name}" end @blocks.push(block) definition.call(block) block end |
#blocks(include_children: false) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/journeyviz/node_group.rb', line 22 def blocks(include_children: false) @blocks ||= [] if include_children @blocks.flat_map { |block| [block] + block.blocks(include_children: true) } else @blocks end end |
#find_screen(qualifier) ⇒ Object
50 51 52 |
# File 'lib/journeyviz/node_group.rb', line 50 def find_screen(qualifier) screens.find { |screen| screen.full_qualifier == qualifier } end |
#inputs ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/journeyviz/node_group.rb', line 54 def inputs = defined?(root_scope) && root_scope ? root_scope.screens : [] external_screens = - screens self_screens = screens external_screens.select do |screen| screen.actions.any? do |action| self_screens.include?(action.transition) end end end |
#outputs ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/journeyviz/node_group.rb', line 65 def outputs screens .flat_map(&:actions) .map(&:transition) .compact .reject { |screen| screens.include?(screen) } end |
#screen(name) {|screen| ... } ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/journeyviz/node_group.rb', line 32 def screen(name) @screens ||= [] screen = Screen.new(name, self) if @screens.any? { |defined_screen| screen.name == defined_screen.name } raise DuplicatedDefinition, "Duplicated screen name: #{name}" end @screens.push(screen) yield screen if block_given? screen end |
#screens ⇒ Object
45 46 47 48 |
# File 'lib/journeyviz/node_group.rb', line 45 def screens @screens ||= [] @screens + blocks.flat_map(&:screens) end |