module EJX::Template::ParseHelpers
Attributes
matched[RW]
Public Instance Methods
current_line()
click to toggle source
# File lib/ejx/template/parse_helpers.rb, line 32 def current_line start = (@source.rindex("\n", @old_index) || 0) + 1 uptop = @source.index("\n", @index) || (@old_index + @matched.length) @source[start..uptop] end
cursor()
click to toggle source
# File lib/ejx/template/parse_helpers.rb, line 38 def cursor start = (@source.rindex("\n", @old_index) || 0) + 1 uptop = @source.index("\n", @index) || (@old_index + @matched.length) lineno = @source[0..start].count("\n") + 1 "#{lineno.to_s.rjust(4)}: " + @source[start..uptop] + "\n #{'-'* (@old_index-start)}#{'^'*(@matched.length)}" end
eos?()
click to toggle source
# File lib/ejx/template/parse_helpers.rb, line 5 def eos? @index >= @source.size end
pre_match()
click to toggle source
# File lib/ejx/template/parse_helpers.rb, line 18 def pre_match @source[@old_index...(@index-@matched.size)] end
rewind(by=1)
click to toggle source
# File lib/ejx/template/parse_helpers.rb, line 22 def rewind(by=1) @index -= by end
scan_until(r)
click to toggle source
# File lib/ejx/template/parse_helpers.rb, line 9 def scan_until(r) index = @source.index(r, @index) match = @source.match(r, @index) @matched = match.to_s @old_index = @index @index = index + @matched.size match end
seek(pos)
click to toggle source
# File lib/ejx/template/parse_helpers.rb, line 26 def seek(pos) @old_index = nil @matched = nil @index = pos end