Class: Hash

Inherits:
Object show all
Defined in:
lib/build/jake.rb,
lib/extensions/mspec/mspec/pp.rb,
lib/framework/indifferent_access.rb,
lib/framework/rholang/localization_simplified.rb

Instance Method Summary collapse

Instance Method Details

#fetch_r(key) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/build/jake.rb', line 41

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



719
720
721
# File 'lib/extensions/mspec/mspec/pp.rb', line 719

def pretty_print(q)
  q.pp_hash self
end

#pretty_print_cycle(q) ⇒ Object



723
724
725
# File 'lib/extensions/mspec/mspec/pp.rb', line 723

def pretty_print_cycle(q)
  q.text(empty? ? '{}' : '{...}')
end

#reverse_merge(other_hash) ⇒ Object



92
93
94
# File 'lib/framework/rholang/localization_simplified.rb', line 92

def reverse_merge(other_hash)
    other_hash.merge(self)
end

#reverse_merge!(other_hash) ⇒ Object



96
97
98
# File 'lib/framework/rholang/localization_simplified.rb', line 96

def reverse_merge!(other_hash)
    replace(reverse_merge(other_hash))
end

#stringify_keysObject



100
101
102
103
104
105
106
107
108
# File 'lib/framework/rholang/localization_simplified.rb', line 100

def stringify_keys
  options = {}
  
  each_pair do |key, value|
    options[key.to_s] = value
  end
  
  options
end

#symbolize_keysObject



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_accessObject



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