Top Level Namespace

Constant Summary collapse

Backtrace_Array_Version =
"0.1.0"

Instance Method Summary collapse

Instance Method Details

#Backtrace_Array(str_or_array) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/Backtrace_Array.rb', line 3

def Backtrace_Array str_or_array
  arr = if str_or_array.is_a?(Enumerable)
          str_or_array
        else
          Split_Lines str_or_array
        end

  last_file = nil
  final = []
  arr.each { |l|
    pieces = l.split( %r!:(\d+):! )
    file = pieces.shift
    num  = pieces.shift
    (num = Integer num) if num
    code = pieces.join(':') unless pieces.empty?

    if last_file != file
      final << [ file, [] ]
      last_file = file
    end

    content_arr = [num, code].compact
    (final.last.last << content_arr) unless content_arr.empty?
  }

  final
end