class Puppet::Pops::Parser::Locator

Helper class that keeps track of where line breaks are located and can answer questions about positions.

Constants

LOCATOR_VERSION
MULTIBYTE

Constant set to true if multibyte is supported (includes multibyte extended regular expressions)

RUBYVER
RUBYVER_ARRAY
RUBY_1_9_3
RUBY_2_0_0

Public Instance Methods

char_length(offset, end_offset) click to toggle source

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
char_offset(byte_offset) click to toggle source

Returns the character offset for a given reported offset

# File lib/puppet/pops/parser/locator.rb, line 61
def char_offset(byte_offset)
end
file() click to toggle source

Returns the file name associated with the string content

# File lib/puppet/pops/parser/locator.rb, line 40
def file
end
line_for_offset(offset) click to toggle source

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
line_index() click to toggle source

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
offset_on_line(offset) click to toggle source

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
pos_on_line(offset) click to toggle source

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
string() click to toggle source

Returns the string content

# File lib/puppet/pops/parser/locator.rb, line 44
def string
end

Public Class Methods

locator(string, file, index = nil) click to toggle source

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
locator_version() click to toggle source

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