Class: WhyClasses::SourceFile
- Inherits:
-
Object
- Object
- WhyClasses::SourceFile
- Defined in:
- lib/why_classes/source_file.rb
Overview
A single Ruby source file: its path, raw source and lazily-parsed AST.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
- #ast ⇒ Object
- #buffer ⇒ Object
- #comments ⇒ Object
-
#initialize(path, source) ⇒ SourceFile
constructor
A new instance of SourceFile.
- #parse_error ⇒ Object
- #parsed? ⇒ Boolean
- #result ⇒ Object
Constructor Details
#initialize(path, source) ⇒ SourceFile
Returns a new instance of SourceFile.
14 15 16 17 |
# File 'lib/why_classes/source_file.rb', line 14 def initialize(path, source) @path = path @source = source end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/why_classes/source_file.rb', line 8 def path @path end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
19 20 21 |
# File 'lib/why_classes/source_file.rb', line 19 def source @source end |
Class Method Details
.from_path(path) ⇒ Object
10 11 12 |
# File 'lib/why_classes/source_file.rb', line 10 def self.from_path(path) new(path, File.read(path)) end |
Instance Method Details
#ast ⇒ Object
25 26 27 |
# File 'lib/why_classes/source_file.rb', line 25 def ast result.ast end |
#buffer ⇒ Object
29 30 31 |
# File 'lib/why_classes/source_file.rb', line 29 def buffer result.buffer end |
#comments ⇒ Object
33 34 35 |
# File 'lib/why_classes/source_file.rb', line 33 def comments result.comments end |
#parse_error ⇒ Object
41 42 43 |
# File 'lib/why_classes/source_file.rb', line 41 def parse_error result.error end |
#parsed? ⇒ Boolean
37 38 39 |
# File 'lib/why_classes/source_file.rb', line 37 def parsed? !ast.nil? end |