Class: Temill::SourceFile
- Inherits:
-
Object
- Object
- Temill::SourceFile
- Defined in:
- lib/temill/core.rb
Defined Under Namespace
Classes: InsertionPoint, InsertionPointSet
Instance Attribute Summary collapse
-
#insertion_points ⇒ Object
readonly
Returns the value of attribute insertion_points.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#sexp ⇒ Object
readonly
Returns the value of attribute sexp.
Class Method Summary collapse
Instance Method Summary collapse
- #add_result(caller_loc, v, with_block) ⇒ Object
- #each_source_line(&block) ⇒ Object
-
#initialize(src, path, options) ⇒ SourceFile
constructor
A new instance of SourceFile.
Constructor Details
#initialize(src, path, options) ⇒ SourceFile
Returns a new instance of SourceFile.
140 141 142 143 144 145 146 |
# File 'lib/temill/core.rb', line 140 def initialize(src, path, ) @path = path @lines = [nil] + src.lines @sexp = Ruby23Parser.new.parse(src, path).value @options = @insertion_points = InsertionPointSet.new end |
Instance Attribute Details
#insertion_points ⇒ Object (readonly)
Returns the value of attribute insertion_points.
138 139 140 |
# File 'lib/temill/core.rb', line 138 def insertion_points @insertion_points end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
137 138 139 |
# File 'lib/temill/core.rb', line 137 def lines @lines end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
137 138 139 |
# File 'lib/temill/core.rb', line 137 def path @path end |
#sexp ⇒ Object (readonly)
Returns the value of attribute sexp.
137 138 139 |
# File 'lib/temill/core.rb', line 137 def sexp @sexp end |
Class Method Details
.from_inline_source(src, virtual_path, options) ⇒ Object
148 149 150 |
# File 'lib/temill/core.rb', line 148 def self.from_inline_source(src, virtual_path, ) new(src, virtual_path, ) end |
.from_path(path, options) ⇒ Object
152 153 154 |
# File 'lib/temill/core.rb', line 152 def self.from_path(path, ) new(File.read(path), path, ) end |
Instance Method Details
#add_result(caller_loc, v, with_block) ⇒ Object
159 160 161 162 163 164 165 166 |
# File 'lib/temill/core.rb', line 159 def add_result(caller_loc, v, with_block) caller_lineno = caller_loc.lineno unless @insertion_points.at_caller_lineno(caller_lineno) @insertion_points.add(make_insertion_point(caller_loc, with_block)) end @insertion_points.at_caller_lineno(caller_lineno) << v self end |
#each_source_line(&block) ⇒ Object
168 169 170 171 172 173 |
# File 'lib/temill/core.rb', line 168 def each_source_line(&block) return enum_for(__method__) unless block 1.upto(@lines.size-1){| i | block.call(@lines[i], i) } end |