Method: Effective::CodeReader#each_with_depth

Defined in:
app/models/effective/code_reader.rb

#each_with_depth(from: nil, to: nil, &block) ⇒ Object

Iterate over the lines with a depth, and passed the stripped line to the passed block



11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/effective/code_reader.rb', line 11

def each_with_depth(from: nil, to: nil, &block)
  Array(lines).each_with_index do |line, index|
    next if index < (from || 0)

    depth = line.length - line.lstrip.length
    block.call(line.strip, depth, index)

    break if to == index
  end

  nil
end