Class: Cadenza::GenericBlockNode

Inherits:
Object
  • Object
show all
Defined in:
lib/cadenza/nodes/generic_block_node.rb

Overview

The GenericBlockNode allows the end user of Cadenza to provide custom block rendering logic via a proc defined on Context.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier, children, parameters = []) ⇒ GenericBlockNode

Creates a new generic block with the given name, children and parameters.

Parameters:

  • identifier (String)

    the name of the node as defined in Context

  • children (Array)

    the child nodes belonging to this block

  • parameters (Array) (defaults to: [])

    the nodes holding the value of parameters passed to this block.



20
21
22
23
24
# File 'lib/cadenza/nodes/generic_block_node.rb', line 20

def initialize(identifier, children, parameters=[])
   @identifier = identifier
   @children = children
   @parameters = parameters
end

Instance Attribute Details

#childrenArray

Returns a list of Node objects which are this block’s child nodes.

Returns:

  • (Array)

    a list of Node objects which are this block’s child nodes



9
10
11
# File 'lib/cadenza/nodes/generic_block_node.rb', line 9

def children
  @children
end

#identifierString

Returns the name of the block as defined in Context.

Returns:

  • (String)

    the name of the block as defined in Context



6
7
8
# File 'lib/cadenza/nodes/generic_block_node.rb', line 6

def identifier
  @identifier
end

#parametersArray

Returns a list of Node objects which hold the value of parameters passed to this block.

Returns:

  • (Array)

    a list of Node objects which hold the value of parameters passed to this block.



13
14
15
# File 'lib/cadenza/nodes/generic_block_node.rb', line 13

def parameters
  @parameters
end

Instance Method Details

#==(rhs) ⇒ Boolean

Returns true if the given node is equivalent by value to the current node.

Parameters:

Returns:

  • (Boolean)

    true if the given node is equivalent by value to the current node.



36
37
38
39
40
# File 'lib/cadenza/nodes/generic_block_node.rb', line 36

def ==(rhs)
   @identifier == rhs.identifier and
   @children == rhs.children and
   @parameters == rhs.parameters
end

#implied_globalsArray

Note:

not yet implemented

Returns a list of variable names implied to be globals in the node.

Returns:

  • (Array)

    a list of variable names implied to be globals in the node



28
29
30
31
# File 'lib/cadenza/nodes/generic_block_node.rb', line 28

def implied_globals
   #TODO: implement me please, kthxbai
   []
end