Class: Prism::Relocation::CodeUnitColumnsField

Inherits:
Object
  • Object
show all
Defined in:
lib/prism/relocation.rb

Overview

A field representing the start and end code unit columns for a specific encoding.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, encoding) ⇒ CodeUnitColumnsField

Initialize a new field with the associated repository and encoding.



291
292
293
294
295
# File 'lib/prism/relocation.rb', line 291

def initialize(repository, encoding)
  @repository = repository
  @encoding = encoding
  @cache = nil
end

Instance Attribute Details

#encodingObject (readonly)

The associated encoding for the code units.



288
289
290
# File 'lib/prism/relocation.rb', line 288

def encoding
  @encoding
end

#repositoryObject (readonly)

The repository object that is used for lazily creating a code units cache.



285
286
287
# File 'lib/prism/relocation.rb', line 285

def repository
  @repository
end

Instance Method Details

#fields(value) ⇒ Object

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



299
300
301
302
303
304
# File 'lib/prism/relocation.rb', line 299

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