Class: Method

Inherits:
Object show all
Defined in:
lib/spec/test_to_spec/ruby2ruby.rb

Instance Method Summary collapse

Instance Method Details

#defined_inObject



46
47
48
49
50
51
52
53
54
# File 'lib/spec/test_to_spec/ruby2ruby.rb', line 46

def defined_in
  full_name = to_s.split(" ").last.chop
  klass_name = full_name.split(/[\#\.]/).first
  if klass_name.include?("(")
    klass_name = klass_name.split("(").last.chop
  end
  klass = klass_name.split("::").inject(Object){|o,n| o.const_get(n)}
  klass
end

#nameObject



56
57
58
59
# File 'lib/spec/test_to_spec/ruby2ruby.rb', line 56

def name
  full_name = to_s.split(" ").last.chop
  full_name.split(/[\#\.]/).last
end