Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/httpclient/httpclient.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

So that we can access hash values as instance methods



27
28
29
# File 'lib/httpclient/httpclient.rb', line 27

def method_missing( name, *args )
  return self[name.to_s] if self[name.to_s]
end

Instance Method Details

#desym!Object



17
18
19
20
21
22
23
# File 'lib/httpclient/httpclient.rb', line 17

def desym!
  r = Hash.new
  self.each do |k, v|
    r[k.to_s]=v.to_s
  end
  self.replace(r)
end

#to_sObject



9
10
11
12
13
14
15
# File 'lib/httpclient/httpclient.rb', line 9

def to_s
  s = "{ "
  self.each{ |k, v| s << "#{k} => #{v}, " }
  s.chop!
  s.chop!
  s << " }"
end