Class: Hash
- Inherits:
-
Object
show all
- Includes:
- Diff, PpHierarchy
- Defined in:
- lib/pp_hierarchy.rb,
lib/diff.rb,
lib/choose.rb,
lib/r_path.rb,
lib/ordered_hash.rb,
lib/sym_tbl_gsub.rb,
lib/yaml/transform.rb
Overview
Instance Method Summary
collapse
#pp_hierarchy
Methods included from Diff
#diff, #gen_diff
Instance Method Details
#choose(limit = nil, generator = nil) ⇒ Object
40
41
42
|
# File 'lib/choose.rb', line 40
def choose ( limit=nil, generator=nil )
self[keys.choose(limit, generator)]
end
|
#no_diff? ⇒ Boolean
80
81
82
|
# File 'lib/diff.rb', line 80
def no_diff?
self[:different] == {} and self[:missing] == {} and self[:additional] == {}
end
|
#ordered? ⇒ Boolean
222
223
224
|
# File 'lib/ordered_hash.rb', line 222
def ordered?
false
end
|
#regex_path_match(re, trees, args, &block) ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/r_path.rb', line 110
def regex_path_match ( re, trees, args, &block ) trees = (trees || []) + [self] if re.starred?
if re.empty?
trees ||= [self]
trees.each { |tree| block[tree, *args] }
else
seg, tail_re = re.split
each do |key, val|
match_data = seg =~ key.to_s
if match_data
sub_args = args + match_data.to_a[1..-1]
val.regex_path_match(tail_re, trees, sub_args, &block)
end
end
end
end
|
#symtbl_gsub(symtbl) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/sym_tbl_gsub.rb', line 38
def symtbl_gsub ( symtbl )
changed = false
res = self.class.new
each do |k,v|
new_k = k.symtbl_gsub(symtbl)
new_v = v.symtbl_gsub(symtbl)
changed = true if new_k or new_v
res[new_k || k] = (new_v || v)
end
changed ? res : nil
end
|
#yaml_doc_traverse(activated) ⇒ Object
FIXME: Are we sure we want to traverse like that? (by stage)
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/yaml/transform.rb', line 34
def yaml_doc_traverse ( activated )
new_activated = []
sons = []
self.each do |key, value|
activated.each do |n|
new_activated += n.match(key, value)
sons << value unless value.is_a?(String)
end
end
activated += new_activated
sons.yaml_doc_traverse(activated)
end
|