Class: Hash

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

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ Object

lets you specify hash as hash.key this came from CodingInRuby on RubyGarden http://www.rubygarden.org/ruby?CodingInRuby



15
16
17
18
19
20
21
# File 'lib/ogginfo.rb', line 15

def method_missing(meth,*args) 
  if /=$/=~(meth=meth.id2name) then
    self[meth[0...-1]] = (args.length<2 ? args[0] : args)
  else
    self[meth]
  end
end