Class: TypeProf::CodePosition
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
self,
Comparable
|
|
Inherits: | Object |
Defined in: | lib/typeprof/code_range.rb |
Class Method Summary
- .from_lsp(pos)
- .new(lineno, column) ⇒ CodePosition constructor
Instance Attribute Summary
Instance Method Summary
- #<=>(other)
- #==(other) (also: #eql?)
-
#eql?(other)
Alias for #==.
- #hash
-
#inspect
Alias for #to_s.
- #left
- #right
- #to_lsp
- #to_s (also: #inspect)
Constructor Details
.new(lineno, column) ⇒ CodePosition
Class Method Details
.from_lsp(pos)
[ GitHub ]# File 'lib/typeprof/code_range.rb', line 8
def self.from_lsp(pos) new(pos[:line] + 1, pos[:character]) end
Instance Attribute Details
#column (readonly)
[ GitHub ]# File 'lib/typeprof/code_range.rb', line 16
attr_reader :lineno, :column
#lineno (readonly)
[ GitHub ]# File 'lib/typeprof/code_range.rb', line 16
attr_reader :lineno, :column
Instance Method Details
#<=>(other)
[ GitHub ]#==(other) Also known as: #eql?
[ GitHub ]#eql?(other)
Alias for #==.
# File 'lib/typeprof/code_range.rb', line 29
alias eql? ==
#hash
[ GitHub ]# File 'lib/typeprof/code_range.rb', line 31
def hash [@lineno, @column].hash end
#inspect
Alias for #to_s.
# File 'lib/typeprof/code_range.rb', line 39
alias inspect to_s
#left
[ GitHub ]# File 'lib/typeprof/code_range.rb', line 41
def left raise if @column == 0 CodePosition.new(@lineno, @column - 1) end
#right
[ GitHub ]# File 'lib/typeprof/code_range.rb', line 46
def right CodePosition.new(@lineno, @column + 1) end
#to_lsp
[ GitHub ]# File 'lib/typeprof/code_range.rb', line 12
def to_lsp { line: @lineno - 1, character: @column } end
#to_s Also known as: #inspect
[ GitHub ]# File 'lib/typeprof/code_range.rb', line 35
def to_s "(%d,%d)" % [@lineno, @column] end