Module: RegexpTree::ClassMethods

Included in:
RegexpTree
Defined in:
app/models/regexp_tree.rb,
app/models/regexp_parse.rb

Overview

raise “” unless self.constants.include?('Default_options') Parse regexp_string into parse tree for editing

Instance Method Summary collapse

Instance Method Details

#promote(node) ⇒ Object


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/regexp_tree.rb', line 19

def promote(node)
	if node.kind_of?(RegexpTree) then #nested Arrays
		node
	elsif node.kind_of?(Array) then #nested Arrays
		RegexpTree.new(node)
		
	elsif node.instance_of?(String) then 
		RegexpTree.new(RegexpParse.new(node).to_a)
	elsif node.instance_of?(RegexpParse) then 
		RegexpTree.new(node.to_a)
	elsif node.instance_of?(Regexp) then 
		RegexpTree.new(RegexpParse.new(node.source).to_a)
	else
		raise "unexpected node=#{node.inspect}"
	end #if
end