Class: GraphQL::Doctor::Location
- Inherits:
-
Struct
- Object
- Struct
- GraphQL::Doctor::Location
- Defined in:
- lib/graphql/doctor/location.rb
Instance Attribute Summary collapse
-
#end_column ⇒ Object
Returns the value of attribute end_column.
-
#end_line ⇒ Object
Returns the value of attribute end_line.
-
#end_offset ⇒ Object
Returns the value of attribute end_offset.
-
#path ⇒ Object
Returns the value of attribute path.
-
#start_column ⇒ Object
Returns the value of attribute start_column.
-
#start_line ⇒ Object
Returns the value of attribute start_line.
-
#start_offset ⇒ Object
Returns the value of attribute start_offset.
Class Method Summary collapse
Instance Method Summary collapse
- #code_units_columns(encoding = Encoding::UTF_16LE, source: nil) ⇒ Object
- #end_code_units_column(encoding = Encoding::UTF_16LE) ⇒ Object
-
#initialize(**attributes) ⇒ Location
constructor
A new instance of Location.
- #start_code_units_column(encoding = Encoding::UTF_16LE) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(**attributes) ⇒ Location
Returns a new instance of Location.
11 12 13 14 |
# File 'lib/graphql/doctor/location.rb', line 11 def initialize(**attributes) super freeze end |
Instance Attribute Details
#end_column ⇒ Object
Returns the value of attribute end_column
7 8 9 |
# File 'lib/graphql/doctor/location.rb', line 7 def end_column @end_column end |
#end_line ⇒ Object
Returns the value of attribute end_line
7 8 9 |
# File 'lib/graphql/doctor/location.rb', line 7 def end_line @end_line end |
#end_offset ⇒ Object
Returns the value of attribute end_offset
7 8 9 |
# File 'lib/graphql/doctor/location.rb', line 7 def end_offset @end_offset end |
#path ⇒ Object
Returns the value of attribute path
7 8 9 |
# File 'lib/graphql/doctor/location.rb', line 7 def path @path end |
#start_column ⇒ Object
Returns the value of attribute start_column
7 8 9 |
# File 'lib/graphql/doctor/location.rb', line 7 def start_column @start_column end |
#start_line ⇒ Object
Returns the value of attribute start_line
7 8 9 |
# File 'lib/graphql/doctor/location.rb', line 7 def start_line @start_line end |
#start_offset ⇒ Object
Returns the value of attribute start_offset
7 8 9 |
# File 'lib/graphql/doctor/location.rb', line 7 def start_offset @start_offset end |
Class Method Details
.from_h(hash) ⇒ Object
28 29 30 |
# File 'lib/graphql/doctor/location.rb', line 28 def self.from_h(hash) new(**hash.transform_keys(&:to_sym)) end |
.from_prism(path, location) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/graphql/doctor/location.rb', line 16 def self.from_prism(path, location) new( path: path, start_line: location.start_line, end_line: location.end_line, start_column: location.start_column, end_column: location.end_column, start_offset: location.start_offset, end_offset: location.end_offset ) end |
Instance Method Details
#code_units_columns(encoding = Encoding::UTF_16LE, source: nil) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/graphql/doctor/location.rb', line 44 def code_units_columns(encoding = Encoding::UTF_16LE, source: nil) source ||= Prism.parse(File.binread(path)).source [source.code_units_column(start_offset, encoding), source.code_units_column(end_offset, encoding)] rescue SystemCallError, EncodingError, RuntimeError [start_column, end_column] end |
#end_code_units_column(encoding = Encoding::UTF_16LE) ⇒ Object
40 41 42 |
# File 'lib/graphql/doctor/location.rb', line 40 def end_code_units_column(encoding = Encoding::UTF_16LE) code_units_columns(encoding).last end |
#start_code_units_column(encoding = Encoding::UTF_16LE) ⇒ Object
36 37 38 |
# File 'lib/graphql/doctor/location.rb', line 36 def start_code_units_column(encoding = Encoding::UTF_16LE) code_units_columns(encoding).first end |
#to_h ⇒ Object
32 33 34 |
# File 'lib/graphql/doctor/location.rb', line 32 def to_h members.to_h { |name| [name, public_send(name)] } end |