class Patch::Node::Container
A container for Patch::Node
Attributes
nodes[R]
Public Class Methods
new(nodes)
click to toggle source
@param [Array<Object>] nodes
# File lib/patch/node/container.rb, line 15 def initialize(nodes) @threads = [] @nodes = nodes end
Public Instance Methods
each(&block)
click to toggle source
# File lib/patch/node/container.rb, line 24 def each(&block) @nodes.each(&block) end
enable()
click to toggle source
Enable the nodes in this container @return [Boolean]
# File lib/patch/node/container.rb, line 30 def enable result = @nodes.map { |node| enable_node(node) } result.any? end
find_all_by_type(type)
click to toggle source
Get the nodes of the given type @param [Symbol] :type The type of node (eg :midi) @return [Array<IO::MIDI, IO::OSC
, IO::Websocket
>]
# File lib/patch/node/container.rb, line 38 def find_all_by_type(type) if (mod = IO::Module.find_by_key(type)).nil? [] else @nodes.select { |node| node.class.name.match(/\A#{mod.name}/) } end end
find_by_id(id)
click to toggle source
Find the node with the given id @param [Fixnum] id @return [IO::MIDI, IO::OSC
, IO::Websocket
]
# File lib/patch/node/container.rb, line 49 def find_by_id(id) @nodes.find { |node| node.id == id } end
|(other)
click to toggle source
# File lib/patch/node/container.rb, line 20 def |(other) @nodes | other.nodes end
Private Instance Methods
enable_node(node)
click to toggle source
Enable the given node @param [Patch::Node] node @return [Boolean]
# File lib/patch/node/container.rb, line 58 def enable_node(node) if node.respond_to?(:start) && !node.active? @threads << ::Patch::Thread.new { node.start } end true end