Class: Method

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

Instance Method Summary collapse

Instance Method Details

#to_sexpObject



19
20
21
22
23
# File 'lib/ambition/lib/proc_to_ruby.rb', line 19

def to_sexp
  with_class_and_method_name do |klass, method|
    ParseTree.new(false).parse_tree_for_method(klass, method)
  end
end

#with_class_and_method_nameObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/ambition/lib/proc_to_ruby.rb', line 8

def with_class_and_method_name
  if self.inspect =~ /<Method: (.*)\#(.*)>/ then
    klass = eval $1
    method  = $2.intern
    raise "Couldn't determine class from #{self.inspect}" if klass.nil?
    return yield(klass, method)
  else
    raise "Can't parse signature: #{self.inspect}"
  end
end