Class: Riml::Nodes

Inherits:
Struct
  • Object
show all
Includes:
Visitable, Walkable
Defined in:
lib/nodes.rb

Overview

Collection of nodes each one representing an expression.

Direct Known Subclasses

SublistNode

Constant Summary

Constants included from Visitable

Visitable::DESCENDANT_OF_REGEX

Instance Attribute Summary collapse

Attributes included from Visitable

#compiled_output, #force_newline, #parent_node, #scope

Instance Method Summary collapse

Methods included from Walkable

#child_after, #child_previous_to, #each, #index_by_children, #index_by_member, #insert_after, #insert_before, #next, #previous, #remove, #replace_with

Methods included from Visitable

#accept

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

forward missing methods to ‘nodes` array



181
182
183
184
185
186
187
# File 'lib/nodes.rb', line 181

def method_missing(method, *args, &block)
  if nodes.respond_to?(method)
    nodes.send(method, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#nodesObject

Returns the value of attribute nodes

Returns:

  • (Object)

    the current value of nodes



162
163
164
# File 'lib/nodes.rb', line 162

def nodes
  @nodes
end

Instance Method Details

#<<(node) ⇒ Object



166
167
168
169
# File 'lib/nodes.rb', line 166

def <<(node)
  nodes << node
  self
end

#[](idx) ⇒ Object



171
172
173
# File 'lib/nodes.rb', line 171

def [](idx)
  nodes[idx]
end

#childrenObject



193
194
195
# File 'lib/nodes.rb', line 193

def children
  nodes
end

#concat(list_of_nodes) ⇒ Object



175
176
177
178
# File 'lib/nodes.rb', line 175

def concat(list_of_nodes)
  nodes.concat(list_of_nodes)
  self
end

#respond_to?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


189
190
191
# File 'lib/nodes.rb', line 189

def respond_to?(method, include_private = false)
  super || nodes.respond_to?(method, include_private)
end