Class: Hash
- Inherits:
-
Object
show all
- Defined in:
- lib/framework/pp.rb,
lib/build/jake.rb,
lib/framework/indifferent_access.rb,
lib/framework/rholang/localization_simplified.rb
Overview
Instance Method Summary
collapse
Instance Method Details
#fetch_r(key) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/build/jake.rb', line 46
def fetch_r(key)
if self.has_key?(key) and not self[key].is_a?(Hash)
return self[key]
else
self.each do |val|
value = false
if val.is_a?(Array)
val.each do |x|
value = x.fetch_r(key) if x.is_a?(Hash)
return value if value
end
end
value = val.fetch_r(key) if val.is_a?(Hash)
return value if value
end
end
return false
end
|
#pretty_print(q) ⇒ Object
372
373
374
|
# File 'lib/framework/pp.rb', line 372
def pretty_print(q) q.pp_hash self
end
|
#pretty_print_cycle(q) ⇒ Object
376
377
378
|
# File 'lib/framework/pp.rb', line 376
def pretty_print_cycle(q) q.text(empty? ? '{}' : '{...}')
end
|
#reverse_merge(other_hash) ⇒ Object
94
95
96
|
# File 'lib/framework/rholang/localization_simplified.rb', line 94
def reverse_merge(other_hash)
other_hash.merge(self)
end
|
#reverse_merge!(other_hash) ⇒ Object
98
99
100
|
# File 'lib/framework/rholang/localization_simplified.rb', line 98
def reverse_merge!(other_hash)
replace(reverse_merge(other_hash))
end
|
#stringify_keys ⇒ Object
102
103
104
105
106
107
108
109
110
|
# File 'lib/framework/rholang/localization_simplified.rb', line 102
def stringify_keys
options = {}
each_pair do |key, value|
options[key.to_s] = value
end
options
end
|
#symbolize_keys ⇒ Object
132
133
134
135
136
137
138
|
# File 'lib/framework/indifferent_access.rb', line 132
def symbolize_keys
hash = {}
self.each do |key, value|
hash[(key.to_sym rescue key) || key] = value
end
hash
end
|
#with_indifferent_access ⇒ Object
127
128
129
130
131
|
# File 'lib/framework/indifferent_access.rb', line 127
def with_indifferent_access
hash = HashWithIndifferentAccess.new(self)
hash.default = self.default
hash
end
|