Class: Pry::CodeFile
Constant Summary collapse
- DEFAULT_EXT =
'.rb'
- EXTENSIONS =
List of all supported languages.
{ %w(.py) => :python, %w(.js) => :javascript, %w(.css) => :css, %w(.xml) => :xml, %w(.php) => :php, %w(.html) => :html, %w(.diff) => :diff, %w(.java) => :java, %w(.json) => :json, %w(.c .h) => :c, %w(.rhtml) => :rhtml, %w(.yaml .yml) => :yaml, %w(.cpp .hpp .cc .h .cxx) => :cpp, %w(.rb .ru .irbrc .gemspec .pryrc .rake) => :ruby, }
- FILES =
{ %w(Gemfile Rakefile Guardfile Capfile) => :ruby }
Instance Attribute Summary collapse
-
#code_type ⇒ Symbol
readonly
The type of code stored in this wrapper.
Instance Method Summary collapse
-
#code ⇒ String
The code contained in the current ‘@filename`.
-
#initialize(filename, code_type = type_from_filename(filename)) ⇒ CodeFile
constructor
A new instance of CodeFile.
Constructor Details
#initialize(filename, code_type = type_from_filename(filename)) ⇒ CodeFile
Returns a new instance of CodeFile.
33 34 35 36 |
# File 'lib/pry/code/code_file.rb', line 33 def initialize(filename, code_type = type_from_filename(filename)) @filename = filename @code_type = code_type end |
Instance Attribute Details
#code_type ⇒ Symbol (readonly)
Returns The type of code stored in this wrapper.
29 30 31 |
# File 'lib/pry/code/code_file.rb', line 29 def code_type @code_type end |
Instance Method Details
#code ⇒ String
Returns The code contained in the current ‘@filename`.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pry/code/code_file.rb', line 39 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 |