Module: Ruby

Defined in:
lib/flickru/ruby.rb

Class Method Summary collapse

Class Method Details

.assert(msg = nil) ⇒ Object



3
4
5
6
7
# File 'lib/flickru/ruby.rb', line 3

def self.assert msg=nil
  if $DEBUG
    raise ArgumentError, msg || "assertion failed" unless yield
  end
end

.caller_method_nameObject



9
10
11
# File 'lib/flickru/ruby.rb', line 9

def self.caller_method_name
  parse_caller(caller(2).first).last
end

.parse_caller(at) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/flickru/ruby.rb', line 15

def self.parse_caller at
  if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
    file = Regexp.last_match[1]
    line = Regexp.last_match[2].to_i
    method = Regexp.last_match[3]
    [file, line, method]
  end
end