class Foo
def initialize x
if x>0
def positive
end
else
def negative
end
end
end
end
f = Foo.new 1
f.positive
class Foo
def initialize x
if x>0
define_singleton_method(:positive) { puts 'positive' }
else
define_singleton_method(:negative) { puts 'negative' }
end
end
end