# module Byebug::FileFunctions

Utilities for interaction with files

### Public Instance Methods

get_line(filename, lineno) click to toggle source

Reads line number `lineno` from file named `filename`

    # File lib/byebug/helper.rb, line 16
    def get_line(filename, lineno)
      File.open(filename) do |f|
        f.gets until f.lineno == lineno - 1
        f.gets
      end
    end

get_lines(filename) click to toggle source

Reads lines of source file `filename` into an array

    # File lib/byebug/helper.rb, line 9
    def get_lines(filename)
      File.foreach(filename).reduce([]) { |a, e| a << e.chomp }
    end

n_lines(filename) click to toggle source

Returns the number of lines in file `filename` in a portable, one-line-at-a-time way.

    # File lib/byebug/helper.rb, line 27
    def n_lines(filename)
      File.foreach(filename).reduce(0) { |a, _e| a + 1 }
    end

normalize(filename) click to toggle source

Regularize file name.

    # File lib/byebug/helper.rb, line 34
    def normalize(filename)
      return filename if ['(irb)', '-e'].include?(filename)

      return File.basename(filename) if Setting[:basename]

      path = File.expand_path(filename)

      File.exist?(path) ? File.realpath(path) : filename
    end