R
raymond medeiros
------=_Part_843_29935623.1127542973065
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
it seemed like a good idea at the time but honestly, hindsight being 20/20 =
i
have no idea what i'd do with this:
class OpenClass
#create the new method
def add_member(name, new_proc)
self.instance_eval %{
def #{name}
#{new_proc}
end
}
end
#there are no predefined methods so we'll add them dynamically
def method_missing(method, *args)
new_proc =3D args[0]
mname =3D method.to_s.gsub(/=3D/, "")
add_member(mname, new_proc)
end
end
o =3D OpenClass.new
o.test_method =3D %{ puts "test_method" }
o.test_method
irb(main):001:0> o =3D OpenClass.new
=3D> #<OpenClass:0xb7d305cc>
irb(main):002:0> o.test_method =3D %{ puts "test" }
=3D> " puts \"test\" "
irb(main):003:0> o.test_method
test
=3D> nil
irb(main):004:0>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
it seemed like a good idea at the time but honestly, hindsight being 20/20 =
i
have no idea what i'd do with this:
class OpenClass
#create the new method
def add_member(name, new_proc)
self.instance_eval %{
def #{name}
#{new_proc}
end
}
end
#there are no predefined methods so we'll add them dynamically
def method_missing(method, *args)
new_proc =3D args[0]
mname =3D method.to_s.gsub(/=3D/, "")
add_member(mname, new_proc)
end
end
o =3D OpenClass.new
o.test_method =3D %{ puts "test_method" }
o.test_method
irb(main):001:0> o =3D OpenClass.new
=3D> #<OpenClass:0xb7d305cc>
irb(main):002:0> o.test_method =3D %{ puts "test" }
=3D> " puts \"test\" "
irb(main):003:0> o.test_method
test
=3D> nil
irb(main):004:0>