Class: Puppet::Pops::Parser::Locator::LocatorForChars

Inherits:
AbstractLocator show all
Defined in:
lib/puppet/pops/parser/locator.rb

Instance Attribute Summary

Attributes inherited from AbstractLocator

#file, #line_index, #string

Instance Method Summary collapse

Methods inherited from AbstractLocator

#ary_bsearch_i, #eql?, #hash, #initialize, #line_for_offset, #pos_on_line, #to_location_hash

Methods inherited from Puppet::Pops::Parser::Locator

compute_line_index, #extract_tree_text, #file, #line_for_offset, #line_index, locator, #pos_on_line, #string, #to_s, #to_uri

Constructor Details

This class inherits a constructor from Puppet::Pops::Parser::Locator::AbstractLocator

Instance Method Details

#char_length(offset, end_offset) ⇒ Object



298
299
300
# File 'lib/puppet/pops/parser/locator.rb', line 298

def char_length(offset, end_offset)
  end_offset - offset
end

#char_offset(char_offset) ⇒ Object



294
295
296
# File 'lib/puppet/pops/parser/locator.rb', line 294

def char_offset(char_offset)
  char_offset
end

#extract_text(offset, length) ⇒ Object

Extracts the text from char offset with given byte length



304
305
306
# File 'lib/puppet/pops/parser/locator.rb', line 304

def extract_text(offset, length)
  string.slice(offset, length)
end

#offset_on_line(offset) ⇒ Object



289
290
291
292
# File 'lib/puppet/pops/parser/locator.rb', line 289

def offset_on_line(offset)
  line_offset = line_index[ line_for_offset(offset)-1 ]
  offset - line_offset
end