class Prism::Relocation::CodeUnitOffsetsField

A field representing the start and end code unit offsets.

Attributes

The associated encoding for the code units.

A pointer to the repository object that is used for lazily creating a code units cache.

Public Class Methods

Initialize a new field with the associated repository and encoding.

# File lib/prism/relocation.rb, line 237
def initialize(repository, encoding)
  @repository = repository
  @encoding = encoding
  @cache = nil
end

Public Instance Methods

Fetches the start and end code units offset of a value for a particular encoding.

# File lib/prism/relocation.rb, line 245
def fields(value)
  {
    start_code_units_offset: value.cached_start_code_units_offset(cache),
    end_code_units_offset: value.cached_end_code_units_offset(cache)
  }
end