Class: ArchSpec::SourceLocation

Inherits:
Data
  • Object
show all
Defined in:
lib/archspec/source_location.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column

Returns:

  • (Object)

    the current value of column



4
5
6
# File 'lib/archspec/source_location.rb', line 4

def column
  @column
end

#lineObject (readonly)

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



4
5
6
# File 'lib/archspec/source_location.rb', line 4

def line
  @line
end

#pathObject (readonly)

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



4
5
6
# File 'lib/archspec/source_location.rb', line 4

def path
  @path
end

Class Method Details

.from_prism(path, location) ⇒ Object



5
6
7
# File 'lib/archspec/source_location.rb', line 5

def self.from_prism(path, location)
  new(path, location.start_line, location.start_column + 1)
end

Instance Method Details

#relative_path(root) ⇒ Object



9
10
11
12
13
# File 'lib/archspec/source_location.rb', line 9

def relative_path(root)
  Pathname(path).relative_path_from(Pathname(root)).to_s
rescue ArgumentError
  path
end