|
def initialize(arg, respect_whitespace=false, parent=nil, pattern=PATTERN, raw=false)
@raw = raw
if parent
if parent == true
@raw = true
@parent = nil
elsif parent.kind_of? Parent
super( parent )
@raw = parent.raw
end
else
@parent = nil
end
if arg.kind_of? Source
# OPTIMIZE
# We've got two lines to do one search. Can we improve this?
arg.match(PATTERN_SEARCH)
md = arg.match(pattern, true)
raise "no text to add" if md[0].length == 0
@string = md[1]
@string.squeeze!(" \n\t") unless respect_whitespace
@normalized = true
#@string = Node::read_with_substitution(@string, ILLEGAL) unless @raw
elsif arg.kind_of? String
@string = arg.clone
@string.squeeze!(" \n\t") unless respect_whitespace
@normalized = false
#@string = Text::normalize(@string) unless @raw
#@string = Node::read_with_substitution(@string) unless @raw
elsif arg.kind_of? Text
@string = arg.string
@raw = arg.raw
@normalized = true
elsif arg.kind_of? Parent
super( arg )
elsif [true,false].include? arg
@raw = arg
end
end
|