Ruby でオブジェクトのメソッドへの参照を取得することは可能ですか (これが procs/lambdas なしで実行できるかどうか知りたいです)。たとえば、次のコードを検討してください。
class X
def initialize
@map = {}
setup_map
end
private
def setup_map
# @map["a"] = get reference to a method
# @map["b"] = get reference to b method
# @map["c"] = get referebce to c method
end
public
def call(a)
@map["a"](a) if a > 10
@map["b"](a) if a > 20
@map["c"](a) if a > 30
end
def a(arg)
puts "a was called with #{arg}"
end
def b(arg)
puts "b was called with #{arg}"
end
def c(arg)
puts "c was called with #{arg}"
end
end
そのようなことは可能ですか?サブクラス化によって A、B、C の動作を変更できるようにしたいので、procs/lambdas を避けたいと思います。