Class: Prism::Relocation::CodeUnitOffsetsField
| Relationships & Source Files | |
| Inherits: | Object | 
| Defined in: | lib/prism/relocation.rb | 
Overview
A field representing the start and end code unit offsets.
Class Method Summary
- 
    
      .new(repository, encoding)  ⇒ CodeUnitOffsetsField 
    
    constructor
    
Initialize a new field with the associated repository and encoding.
 
Instance Attribute Summary
- 
    
      #encoding  
    
    readonly
    
The associated encoding for the code units.
 - 
    
      #repository  
    
    readonly
    
A pointer to the repository object that is used for lazily creating a code units cache.
 
Instance Method Summary
- 
    
      #fields(value)  
    
    
Fetches the start and end code units offset of a value for a particular encoding.
 - 
    
      #cache  
    
    private
    
Lazily create a code units cache for the associated encoding.
 
Constructor Details
    .new(repository, encoding)  ⇒ CodeUnitOffsetsField 
  
Initialize a new field with the associated repository and encoding.
# File 'lib/prism/relocation.rb', line 238
def initialize(repository, encoding) @repository = repository @encoding = encoding @cache = nil end
Instance Attribute Details
#encoding (readonly)
The associated encoding for the code units.
# File 'lib/prism/relocation.rb', line 235
attr_reader :encoding
#repository (readonly)
A pointer to the repository object that is used for lazily creating a code units cache.
# File 'lib/prism/relocation.rb', line 232
attr_reader :repository
Instance Method Details
#cache (private)
Lazily create a code units cache for the associated encoding.
# File 'lib/prism/relocation.rb', line 256
def cache @cache ||= repository.code_units_cache(encoding) end
#fields(value)
Fetches the start and end code units offset of a value for a particular encoding.