Class: Ripe::Blocks::Block Abstract
- Inherits:
-
Object
- Object
- Ripe::Blocks::Block
- Defined in:
- lib/ripe/blocks.rb,
lib/ripe/blocks/block.rb
Overview
This class represents the fundamental building block of ripe.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#blocks ⇒ Array<Block>
readonly
list of children blocks.
-
#id ⇒ String
readonly
a mandatory, but optionally unique identifier for the block.
-
#vars ⇒ Hash<Symbol, String>
key-value pairs.
Instance Method Summary collapse
-
#+(block) ⇒ Block
Compose a new serial block from two blocks.
-
#command ⇒ String
Return the string command of the subtree starting at the current block.
-
#initialize(id, blocks = [], vars = {}) ⇒ Block
constructor
Create a new, empty Block.
-
#prune(protect, depend) ⇒ Block?
Prune the subtree starting at the current block.
-
#targets_exist? ⇒ Boolean
Test whether all targets for the current block exist.
-
#topology ⇒ Array<Symbol, Array>
Return the topology of the subtree starting at the current block in a nested list format.
-
#|(block) ⇒ Block
Compose a new parallel block from two blocks.
Constructor Details
#initialize(id, blocks = [], vars = {}) ⇒ Block
Create a new, empty Ripe::Blocks::Block.
31 32 33 |
# File 'lib/ripe/blocks/block.rb', line 31 def initialize(id, blocks = [], vars = {}) @id, @blocks, @vars = id, blocks, vars end |
Instance Attribute Details
#blocks ⇒ Array<Block> (readonly)
list of children blocks
17 18 19 |
# File 'lib/ripe/blocks/block.rb', line 17 def blocks @blocks end |
#id ⇒ String (readonly)
a mandatory, but optionally unique identifier for the block
17 18 19 |
# File 'lib/ripe/blocks/block.rb', line 17 def id @id end |
#vars ⇒ Hash<Symbol, String>
key-value pairs
17 18 19 |
# File 'lib/ripe/blocks/block.rb', line 17 def vars @vars end |
Instance Method Details
#+(block) ⇒ Block
Compose a new serial block from two blocks. This method provides syntactic sugar in the form:
Block1 + Block2 + Block3
107 108 109 |
# File 'lib/ripe/blocks/block.rb', line 107 def +(block) SerialBlock.new(self, block) end |
#command ⇒ String
Return the string command of the subtree starting at the current block.
40 41 42 |
# File 'lib/ripe/blocks/block.rb', line 40 def command '' end |
#prune(protect, depend) ⇒ Block?
Prune the subtree starting at the current block.
55 56 57 |
# File 'lib/ripe/blocks/block.rb', line 55 def prune(protect, depend) self end |
#targets_exist? ⇒ Boolean
Test whether all targets for the current block exist.
64 65 66 67 68 |
# File 'lib/ripe/blocks/block.rb', line 64 def targets_exist? # {Block} is an abstract class. By default, assume that no targets # exist. false end |
#topology ⇒ Array<Symbol, Array>
Return the topology of the subtree starting at the current block in a nested list format. The first element of any nested list is the identifier of the corresponding block in the subtree, and the subsequent elements are each a subtree corresponding to the children blocks of the current subtree.
79 80 81 |
# File 'lib/ripe/blocks/block.rb', line 79 def topology [] end |
#|(block) ⇒ Block
Compose a new parallel block from two blocks. This method provides syntactic sugar in the form:
Block1 | Block2 | Block3
93 94 95 |
# File 'lib/ripe/blocks/block.rb', line 93 def |(block) ParallelBlock.new(self, block) end |