Class: Zxc::Split

Inherits:
Step
  • Object
show all
Defined in:
lib/zxc/steps/split.rb

Constant Summary

Constants inherited from Step

Zxc::Step::Kind

Instance Method Summary collapse

Methods inherited from Step

#depth_decreased, #depth_increased, #initialize

Constructor Details

This class inherits a constructor from Zxc::Step

Instance Method Details

#run(root) ⇒ Object



11
12
13
14
# File 'lib/zxc/steps/split.rb', line 11

def run(root)
  root.leaves.each { |l| run_leaf(l) }
  depth_increased(root)
end

#run_leaf(node) ⇒ Object



16
17
18
19
20
21
# File 'lib/zxc/steps/split.rb', line 16

def run_leaf(node)
  splitted = node.text.split(@args[0])
  splitted.each do |t|
    node.subnodes << Node.new(t, node)
  end
end