Class: Array

Inherits:
Object show all
Includes:
Diff, Shuffle
Defined in:
lib/shuffle.rb,
lib/diff.rb,
lib/choose.rb,
lib/r_path.rb,
lib/sym_tbl_gsub.rb,
lib/yaml_extensions/transform.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from Shuffle

#shuffle, #shuffle!, #swap, #swap!

Methods included from Diff

#diff, #gen_diff, #no_diff?

Instance Method Details

#choose(limit = nil, generator = nil) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/choose.rb', line 49

def choose ( limit=nil, generator=nil )
  n = size

  # Out of limits: limit > size (FIXME warn)
  limit = n if limit.nil? or limit > n

  self[limit.choose(generator)]
end

#each_pairObject



61
62
63
64
65
# File 'lib/diff.rb', line 61

def each_pair
  for i in 0...length do
    yield(i, self[i])
  end
end

#has_index?(i) ⇒ Boolean Also known as: has_key?

Returns:

  • (Boolean)


67
68
69
# File 'lib/diff.rb', line 67

def has_index?(i)
  0 <= i and i < length
end

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

:nodoc:



140
141
142
143
144
# File 'lib/r_path.rb', line 140

def regex_path_match ( re, trees, args, &block ) # :nodoc:
  each do |x|
    x.regex_path_match(re, trees, args, &block)
  end
end

#symtbl_gsub(symtbl) ⇒ Object



108
109
110
111
112
113
114
115
116
# File 'lib/sym_tbl_gsub.rb', line 108

def symtbl_gsub symtbl
  changed = false
  res = self.class.new
  each do |e|
    changed = true if new_e = e.symtbl_gsub(symtbl)
    res << (new_e || e)
  end
  changed ? res : nil
end

#symtbl_gsub!(symtbl) ⇒ Object



103
104
105
106
# File 'lib/sym_tbl_gsub.rb', line 103

def symtbl_gsub! symtbl
  res = inject(nil) { |accu, x| x.symtbl_gsub!(symtbl) || accu }
  (res.nil?)? nil : self
end

#yaml_doc_traverse(activated) ⇒ Object



49
50
51
# File 'lib/yaml_extensions/transform.rb', line 49

def yaml_doc_traverse ( activated )
  self.each { |e| e.yaml_doc_traverse(activated) }
end