Class: Prism::Relocation::Entry
Relationships & Source Files | |
Namespace Children | |
Exceptions:
| |
Inherits: | Object |
Defined in: | lib/prism/relocation.rb |
Overview
An entry in a repository that will lazily reify its values when they are first accessed.
Class Method Summary
-
.new(repository) ⇒ Entry
constructor
Initialize a new entry with the given repository.
Instance Method Summary
-
#comments
Fetch the leading and trailing comments of the value.
-
#end_character_column
Fetch the end character column of the value.
-
#end_character_offset
Fetch the end character offset of the value.
-
#end_code_units_column
Fetch the end code units column of the value, for the encoding that was configured on the repository.
-
#end_code_units_offset
Fetch the end code units offset of the value, for the encoding that was configured on the repository.
-
#end_column
Fetch the end byte column of the value.
-
#end_line
Fetch the end line of the value.
-
#end_offset
Fetch the end byte offset of the value.
-
#filepath
Fetch the filepath of the value.
-
#leading_comments
Fetch the leading comments of the value.
-
#start_character_column
Fetch the start character column of the value.
-
#start_character_offset
Fetch the start character offset of the value.
-
#start_code_units_column
Fetch the start code units column of the value, for the encoding that was configured on the repository.
-
#start_code_units_offset
Fetch the start code units offset of the value, for the encoding that was configured on the repository.
-
#start_column
Fetch the start byte column of the value.
-
#start_line
Fetch the start line of the value.
-
#start_offset
Fetch the start byte offset of the value.
-
#trailing_comments
Fetch the trailing comments of the value.
-
#fetch_value(name)
private
Fetch a value from the entry, raising an error if it is missing.
-
#values
private
Return the values from the repository, reifying them if necessary.
-
#reify!(values)
Internal use only
Reify the values on this entry with the given values.
Constructor Details
.new(repository) ⇒ Entry
Initialize a new entry with the given repository.
# File 'lib/prism/relocation.rb', line 24
def initialize(repository) @repository = repository @values = nil end
Instance Method Details
#comments
Fetch the leading and trailing comments of the value.
# File 'lib/prism/relocation.rb', line 119
def comments leading_comments.concat(trailing_comments) end
#end_character_column
Fetch the end character column of the value.
# File 'lib/prism/relocation.rb', line 92
def end_character_column fetch_value(:end_character_column) end
#end_character_offset
Fetch the end character offset of the value.
# File 'lib/prism/relocation.rb', line 60
def end_character_offset fetch_value(:end_character_offset) end
#end_code_units_column
Fetch the end code units column of the value, for the encoding that was configured on the repository.
# File 'lib/prism/relocation.rb', line 104
def end_code_units_column fetch_value(:end_code_units_column) end
#end_code_units_offset
Fetch the end code units offset of the value, for the encoding that was configured on the repository.
# File 'lib/prism/relocation.rb', line 72
def end_code_units_offset fetch_value(:end_code_units_offset) end
#end_column
Fetch the end byte column of the value.
# File 'lib/prism/relocation.rb', line 82
def end_column fetch_value(:end_column) end
#end_line
Fetch the end line of the value.
# File 'lib/prism/relocation.rb', line 40
def end_line fetch_value(:end_line) end
#end_offset
Fetch the end byte offset of the value.
# File 'lib/prism/relocation.rb', line 50
def end_offset fetch_value(:end_offset) end
#fetch_value(name) (private)
Fetch a value from the entry, raising an error if it is missing.
# File 'lib/prism/relocation.rb', line 134
def fetch_value(name) values.fetch(name) do raise MissingValueError, "No value for #{name}, make sure the " \ "repository has been properly configured" end end
#filepath
Fetch the filepath of the value.
# File 'lib/prism/relocation.rb', line 30
def filepath fetch_value(:filepath) end
#leading_comments
Fetch the leading comments of the value.
# File 'lib/prism/relocation.rb', line 109
def leading_comments fetch_value(:leading_comments) end
#reify!(values)
Reify the values on this entry with the given values. This is an internal-only API that is called from the repository when it is time to reify the values.
#start_character_column
Fetch the start character column of the value.
# File 'lib/prism/relocation.rb', line 87
def start_character_column fetch_value(:start_character_column) end
#start_character_offset
Fetch the start character offset of the value.
# File 'lib/prism/relocation.rb', line 55
def start_character_offset fetch_value(:start_character_offset) end
#start_code_units_column
Fetch the start code units column of the value, for the encoding that was configured on the repository.
# File 'lib/prism/relocation.rb', line 98
def start_code_units_column fetch_value(:start_code_units_column) end
#start_code_units_offset
Fetch the start code units offset of the value, for the encoding that was configured on the repository.
# File 'lib/prism/relocation.rb', line 66
def start_code_units_offset fetch_value(:start_code_units_offset) end
#start_column
Fetch the start byte column of the value.
# File 'lib/prism/relocation.rb', line 77
def start_column fetch_value(:start_column) end
#start_line
Fetch the start line of the value.
# File 'lib/prism/relocation.rb', line 35
def start_line fetch_value(:start_line) end
#start_offset
Fetch the start byte offset of the value.
# File 'lib/prism/relocation.rb', line 45
def start_offset fetch_value(:start_offset) end
#trailing_comments
Fetch the trailing comments of the value.
# File 'lib/prism/relocation.rb', line 114
def trailing_comments fetch_value(:trailing_comments) end
#values (private)
Return the values from the repository, reifying them if necessary.
# File 'lib/prism/relocation.rb', line 142
def values @values || (@repository.reify!; @values) end