Class: String

Inherits:
Object show all
Defined in:
lib/text.rb,
lib/r_path.rb,
lib/sym_tbl_gsub.rb

Instance Method Summary collapse

Instance Method Details

#regex_path_match(re, trees, args, &block) ⇒ Object

:nodoc:



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/r_path.rb', line 151

def regex_path_match ( re, trees, args, &block ) # :nodoc:
  seg, tail_re = re.split

  trees = (trees || []) + [self] if re.captured?

  if tail_re.empty?
    match_data = seg =~ self
    if seg.nil? or match_data
      trees ||= [self]
    else
      trees ||= []
    end
    if seg.nil? or match_data or re.negative?
      args = args + match_data[1..-1] if defined? match_data and match_data
      trees.each { |tree| block[tree, *args] }
    end
  end
end

#symtbl_gsub(symtbl) ⇒ Object



196
197
198
199
# File 'lib/sym_tbl_gsub.rb', line 196

def symtbl_gsub ( symtbl )
  return nil unless self =~ /<<.*>>/
  dup.symtbl_gsub! symtbl
end

#symtbl_gsub!(symtbl) ⇒ Object



203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/sym_tbl_gsub.rb', line 203

def symtbl_gsub! ( symtbl )
  have_changed = nil
  while (
    gsub!(/<<([^<>]*)>>/) do
      s = symtbl[$1]
      have_changed ||= s
      (s.nil?)? "<#{@@tag}<#$1>#{@@tag}>" : s.symtbl_to_s
    end
  ) do
  end
  gsub! @@tag, ''
  return nil if have_changed.nil?
  self
end

#symtbl_to_sObject



192
193
194
# File 'lib/sym_tbl_gsub.rb', line 192

def symtbl_to_s
  self
end

#to_text(*args, &block) ⇒ Object



163
164
165
# File 'lib/text.rb', line 163

def to_text ( *args, &block )
  Text.new(self, *args, &block)
end