Class: Hexp::Node::Rewriter

Inherits:
Object
  • Object
show all
Includes:
Hexp
Defined in:
lib/hexp/node/rewriter.rb

Overview

Create a new Hexp node based on an existing node

Rewriting in this case means iterating over the whole Hexp tree, and for each element providing zero or more elements to replace it with.

Constant Summary

Constant Summary

Constants included from Hexp

Error, VERSION

Instance Method Summary (collapse)

Methods included from Hexp

Array, build, deep_freeze, included, parse

Constructor Details

- (Rewriter) initialize(node, block)

A new instance of Rewriter



11
12
13
# File 'lib/hexp/node/rewriter.rb', line 11

def initialize(node, block)
  @node, @block = node, block
end

Instance Method Details

- (Object) to_hexp



15
16
17
18
19
20
21
# File 'lib/hexp/node/rewriter.rb', line 15

def to_hexp
  @hexp ||= H[
    @node.tag,
    @node.attributes,
    @block ? rewrite_children : @node.children
  ]
end