Class: String

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

Instance Method Summary collapse

Instance Method Details

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

:nodoc:



144
145
146
147
148
149
150
151
152
153
154
# File 'lib/r_path.rb', line 144

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

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

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

#symtbl_gsub(symtbl) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/sym_tbl_gsub.rb', line 124

def symtbl_gsub ( symtbl )
  return nil unless self =~ /<<(.*)>>/
  cur, last = self, nil
  while cur != last
    last = cur
    cur = cur.gsub(/<<([^<>]*)>>/) do
      s = symtbl[$1]
      (s.nil?)? $& : s.symtbl_to_s
    end
  end
  (cur == self)? nil : cur
end

#to_cmdObject

Make a command from a String.

Split your command when no quotations are used.

Do not touch the String and give as one argument.



28
29
30
31
32
33
34
# File 'lib/commands/helpers.rb', line 28

def to_cmd
  if self =~ /['"`]/
    Command.new(self)
  else
    Command.new(*split(/\s+/))
  end
end

#to_io_for_commandsObject



36
37
38
39
40
# File 'lib/commands/helpers.rb', line 36

def to_io_for_commands
  tmp = TempPath.new
  tmp.open('w') { |f| f.write self }
  tmp.to_io_for_commands
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