class Pry::CodeFile

Constants

DEFAULT_EXT
EXTENSIONS

List of all supported languages. @return [Hash]

Attributes

code_type[R]

@return [Symbol] The type of code stored in this wrapper.

Public Class Methods

new(filename, code_type = type_from_filename(filename)) click to toggle source

@param [String] filename The name of a file with code to be detected @param [Symbol] #code_type The type of code the `filename` contains

# File lib/pry/code/code_file.rb, line 29
def initialize(filename, code_type = type_from_filename(filename))
  @filename = filename
  @code_type = code_type
end

Public Instance Methods

code() click to toggle source

@return [String] The code contained in the current `@filename`.

# File lib/pry/code/code_file.rb, line 35
def code
  if @filename == Pry.eval_path
    Pry.line_buffer.drop(1)
  elsif Pry::Method::Patcher.code_for(@filename)
    Pry::Method::Patcher.code_for(@filename)
  elsif RbxPath.is_core_path?(@filename)
    File.read(RbxPath.convert_path_to_full(@filename))
  else
    path = abs_path
    @code_type = type_from_filename(path)
    File.read(path)
  end
end