Class: Cadenza::GenericBlockNode

Inherits:
Object
  • Object
show all
Includes:
TreeNode
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

Methods included from TreeNode

#to_tree

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.


22
23
24
25
26
# File 'lib/cadenza/nodes/generic_block_node.rb', line 22

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


11
12
13
# File 'lib/cadenza/nodes/generic_block_node.rb', line 11

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


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

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.


15
16
17
# File 'lib/cadenza/nodes/generic_block_node.rb', line 15

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.


38
39
40
41
42
# File 'lib/cadenza/nodes/generic_block_node.rb', line 38

def ==(rhs)
   @identifier == rhs.identifier &&
   @children == rhs.children &&
   @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


30
31
32
33
# File 'lib/cadenza/nodes/generic_block_node.rb', line 30

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