Class: RBI::Loc

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/rbi/loc.rb,
lib/rbi/parser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file: nil, begin_line: nil, end_line: nil, begin_column: nil, end_column: nil) ⇒ Loc

Returns a new instance of Loc.



23
24
25
26
27
28
29
# File 'lib/rbi/loc.rb', line 23

def initialize(file: nil, begin_line: nil, end_line: nil, begin_column: nil, end_column: nil)
  @file = file
  @begin_line = begin_line
  @end_line = end_line
  @begin_column = begin_column
  @end_column = end_column
end

Instance Attribute Details

#begin_columnObject (readonly)

Returns the value of attribute begin_column.



12
13
14
# File 'lib/rbi/loc.rb', line 12

def begin_column
  @begin_column
end

#begin_lineObject (readonly)

Returns the value of attribute begin_line.



12
13
14
# File 'lib/rbi/loc.rb', line 12

def begin_line
  @begin_line
end

#end_columnObject (readonly)

Returns the value of attribute end_column.



12
13
14
# File 'lib/rbi/loc.rb', line 12

def end_column
  @end_column
end

#end_lineObject (readonly)

Returns the value of attribute end_line.



12
13
14
# File 'lib/rbi/loc.rb', line 12

def end_line
  @end_line
end

#fileObject (readonly)

Returns the value of attribute file.



9
10
11
# File 'lib/rbi/loc.rb', line 9

def file
  @file
end

Class Method Details

.from_ast_loc(file, ast_loc) ⇒ Object



611
612
613
614
615
616
617
618
619
# File 'lib/rbi/parser.rb', line 611

def self.from_ast_loc(file, ast_loc)
  Loc.new(
    file: file,
    begin_line: ast_loc.line,
    begin_column: ast_loc.column,
    end_line: ast_loc.last_line,
    end_column: ast_loc.last_column
  )
end

Instance Method Details

#to_sObject



32
33
34
# File 'lib/rbi/loc.rb', line 32

def to_s
  "#{file}:#{begin_line}:#{begin_column}-#{end_line}:#{end_column}"
end