Class: Array

Inherits:
Object show all
Defined in:
lib/pp.rb,
lib/csv.rb,
lib/mkmf.rb,
lib/abbrev.rb,
lib/shellwords.rb,
lib/rexml/xpath_parser.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) abbrev(pattern = nil)

Calculates the set of unambiguous abbreviations for the strings in self. If passed a pattern or a string, only the strings matching the pattern or starting with the string are considered.

%w{ car cone }.abbrev   #=> { "ca" => "car", "car" => "car",
                              "co" => "cone", "con" => cone",
                              "cone" => "cone" }


90
91
92
# File 'lib/abbrev.rb', line 90

def abbrev(pattern = nil)
  Abbrev::abbrev(self, pattern)
end

- (Object) dclone



22
23
24
25
26
27
# File 'lib/rexml/xpath_parser.rb', line 22

def dclone
  klone = self.clone
  klone.clear
  self.each{|v| klone << v.dclone}
  klone
end

- (Object) pretty_print(q)



336
337
338
339
340
341
342
# File 'lib/pp.rb', line 336

def pretty_print(q)
  q.group(1, '[', ']') {
    q.seplist(self) {|v|
      q.pp v
    }
  }
end

- (Object) pretty_print_cycle(q)



344
345
346
# File 'lib/pp.rb', line 344

def pretty_print_cycle(q)
  q.text(empty? ? '[]' : '[...]')
end

- (Object) quote

Wraps all strings in escaped quotes if they contain whitespace.



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

def quote
  map {|s| s.quote}
end

- (Object) shelljoin

call-seq:

array.shelljoin => string

Builds a command line string from an argument list array joining all elements escaped for Bourne shell and separated by a space. See Shellwords::shelljoin for details.



153
154
155
# File 'lib/shellwords.rb', line 153

def shelljoin
  Shellwords.join(self)
end

- (Object) to_csv(options = Hash.new)

Equivalent to CSV::generate_line(self, options).



2329
2330
2331
# File 'lib/csv.rb', line 2329

def to_csv(options = Hash.new)
  CSV.generate_line(self, options)
end