Module: Contracts::Support

Defined in:
lib/contracts/support.rb

Class Method Summary collapse

Class Method Details

.method_name(method) ⇒ Object



17
18
19
# File 'lib/contracts/support.rb', line 17

def self.method_name(method)
  method.is_a?(Proc) ? "Proc" : method.name
end

.method_position(method) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/contracts/support.rb', line 4

def self.method_position(method)
  if RUBY_VERSION =~ /^1\.8/
    if method.respond_to?(:__file__)
      method.__file__ + ":" + method.__line__.to_s
    else
      method.inspect
    end
  else
    file, line = method.source_location
    file + ":" + line.to_s
  end
end