Class: String

Inherits:
Object show all
Defined in:
lib/pp.rb,
lib/mkmf.rb,
lib/shellwords.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#funcall_styleObject



26
27
28
# File 'lib/mkmf.rb', line 26

def funcall_style
  /\)\z/ =~ self ? dup : "#{self}()"
end

#pretty_print(q) ⇒ Object

:nodoc:



456
457
458
459
460
461
462
463
464
465
466
467
# File 'lib/pp.rb', line 456

def pretty_print(q) # :nodoc:
  lines = self.lines
  if lines.size > 1
    q.group(0, '', '') do
      q.seplist(lines, lambda { q.text ' +'; q.breakable }) do |v|
        q.pp v
      end
    end
  else
    q.text inspect
  end
end

#quoteObject

Wraps a string in escaped quotes if it contains whitespace.



12
13
14
# File 'lib/mkmf.rb', line 12

def quote
  /\s/ =~ self ? "\"#{self}\"" : "#{self}"
end

#sans_argumentsObject



30
31
32
# File 'lib/mkmf.rb', line 30

def sans_arguments
  self[/\A[^()]+/]
end

#shellescapeObject

call-seq:

str.shellescape => string

Escapes str so that it can be safely used in a Bourne shell command line.

See Shellwords.shellescape for details.



226
227
228
# File 'lib/shellwords.rb', line 226

def shellescape
  Shellwords.escape(self)
end

#shellsplitObject

call-seq:

str.shellsplit => array

Splits str into an array of tokens in the same way the UNIX Bourne shell does.

See Shellwords.shellsplit for details.



215
216
217
# File 'lib/shellwords.rb', line 215

def shellsplit
  Shellwords.split(self)
end

#tr_cppObject

Generates a string used as cpp macro name.



22
23
24
# File 'lib/mkmf.rb', line 22

def tr_cpp
  strip.upcase.tr_s("^A-Z0-9_*", "_").tr_s("*", "P")
end

#unspaceObject

Escape whitespaces for Makefile.



17
18
19
# File 'lib/mkmf.rb', line 17

def unspace
  gsub(/\s/, '\\\\\\&')
end