Method: Wrong::Chunk.from_block
- Defined in:
- lib/wrong/chunk.rb
.from_block(block, depth = 0) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/wrong/chunk.rb', line 11 def self.from_block(block, depth = 0) as_proc = block.to_proc file, line = if as_proc.respond_to? :source_location # in Ruby 1.9, or with Sourcify, it reads the source location from the block as_proc.source_location else # in Ruby 1.8, it reads the source location from the call stack relevant_caller = caller[depth] relevant_caller.split(":") end new(file, line, &block) end |