class Hash
Public Instance Methods
hprint()
click to toggle source
# File lib/hdb/hdb.rb, line 19 def hprint hashView = self.dup #'*ptr' hashView.each { |k, v| hashView[k] = v.object_id if v.class != String and v.class != Fixnum and v.class != NilClass and v.class != Float } puts hashView end
intersect(hash)
click to toggle source
# File lib/hdb/hdb.rb, line 13 def intersect(hash) self.select {|k,v| hash.include?(k)} end
join(separator)
click to toggle source
# File lib/hdb/hdb.rb, line 3 def join(separator) arr = [] self.each do |key, value| arr << "\"#{key}\" = #{value}" end return arr.join(separator) end
symbolize_keys()
click to toggle source
# File lib/hdatastructures/hhash.rb, line 3 def symbolize_keys self.keys.each do |key| self[(key.to_sym rescue key) || key] = self.delete(key) end end
to_js_format()
click to toggle source
# File lib/hdb/hdb.rb, line 28 def to_js_format result = [] self.each do |k, v| tmp = (v.class <= String) ? "#{k}:#{v.to_js_format}" : "#{k}:#{v}" result << tmp end return "{#{result.join(", ")}}" end