class Pry::Command::Cat::FileFormatter - pry-0.10.1 Documentation

# class Pry::Command::Cat::FileFormatter

### Attributes

_pry_[R]
file_with_embedded_line[R]
opts[R]

### Public Class Methods

new(file_with_embedded_line, _pry_, opts) click to toggle source

    # File lib/pry/commands/cat/file_formatter.rb, line 8
    def initialize(file_with_embedded_line, _pry_, opts)
      @file_with_embedded_line = file_with_embedded_line
      @opts = opts
      @_pry_ = _pry_
      @code_from_file = Pry::Code.from_file(file_name)
    end

### Public Instance Methods

file_and_line() click to toggle source

    # File lib/pry/commands/cat/file_formatter.rb, line 22
    def file_and_line
      file_name, line_num = file_with_embedded_line.split(/:(?!\/|\)/)

      [file_name, line_num ? line_num.to_i : nil]
    end

format() click to toggle source

    # File lib/pry/commands/cat/file_formatter.rb, line 15
    def format
      raise CommandError, "Must provide a filename, --in, or --ex." if !file_with_embedded_line

      set_file_and_dir_locals(file_name, _pry_, _pry_.current_context)
      decorate(@code_from_file)
    end