Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/hdb/hdb.rb,
lib/hdb/hmysql.rb,
lib/hdb/hmysql2.rb,
lib/hdatastructures/hhash.rb

Direct Known Subclasses

HField, HRecord

Instance Method Summary collapse

Instance Method Details

#hprintObject



19
20
21
22
23
24
25
26
# 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) ⇒ Object



13
14
15
16
17
# File 'lib/hdb/hdb.rb', line 13

def intersect(hash)

  self.select {|k,v| hash.include?(k)}

end

#join(separator) ⇒ Object



3
4
5
6
7
8
9
10
11
# 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_keysObject



3
4
5
6
7
# 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_formatObject



28
29
30
31
32
33
34
35
# 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