A field representing the start and end code unit columns for a specific encoding.
Attributes
Read
The repository object that is used for lazily creating a code units cache.
Read
The associated encoding for the code units.
Class Methods
lib/prism/relocation.rb
View on GitHub
# File tmp/rubies/ruby-3.4.1/lib/prism/relocation.rb, line 290
def initialize(repository, encoding)
@repository = repository
@encoding = encoding
@cache = nil
end
Initialize a new field with the associated repository and encoding.
Instance Methods
#
lib/prism/relocation.rb
View on GitHub
# File tmp/rubies/ruby-3.4.1/lib/prism/relocation.rb, line 308
def cache
@cache ||= repository.code_units_cache(encoding)
end
Lazily create a code units cache for the associated encoding.
lib/prism/relocation.rb
View on GitHub
# File tmp/rubies/ruby-3.4.1/lib/prism/relocation.rb, line 298
def fields(value)
{
start_code_units_column: value.cached_start_code_units_column(cache),
end_code_units_column: value.cached_end_code_units_column(cache)
}
end
Fetches the start and end code units column of a value for a particular encoding.