Helper class that keeps track of where line breaks are located and can answer questions about positions.
Constant set to true if multibyte is supported (includes multibyte extended regular expressions)
Returns the length measured in number of characters from the given start and end reported offset
# File lib/puppet/pops/parser/locator.rb, line 65 def char_length(offset, end_offset) end
Returns the character offset for a given reported offset
# File lib/puppet/pops/parser/locator.rb, line 61 def char_offset(byte_offset) end
Returns the file name associated with the string content
# File lib/puppet/pops/parser/locator.rb, line 40 def file end
Returns the line number (first line is 1) for the given offset
# File lib/puppet/pops/parser/locator.rb, line 52 def line_for_offset(offset) end
Returns the line index - an array of line offsets for the start position of each line, starting at 0 for the first line.
# File lib/puppet/pops/parser/locator.rb, line 71 def line_index() end
Returns the offset on line (first offset on a line is 0).
# File lib/puppet/pops/parser/locator.rb, line 57 def offset_on_line(offset) end
Returns the position on line (first position on a line is 1)
# File lib/puppet/pops/parser/locator.rb, line 48 def pos_on_line(offset) end
Returns the string content
# File lib/puppet/pops/parser/locator.rb, line 44 def string end
Creates, or recreates a Locator. A Locator is created if index is not given (a scan is then performed of the given source string.
# File lib/puppet/pops/parser/locator.rb, line 30 def self.locator(string, file, index = nil) case LOCATOR_VERSION when :ruby20, :ruby19 Locator19.new(string, file, index) else Locator18.new(string, file, index) end end
Computes a symbol representing which ruby runtime this is running on This implementation will fail if there are more than 255 minor or micro versions of ruby
# File lib/puppet/pops/parser/locator.rb, line 13 def self.locator_version if RUBYVER >= RUBY_2_0_0 :ruby20 elsif RUBYVER >= RUBY_1_9_3 :ruby19 else :ruby18 end end