Class: Mutiny::Mutants::Mutant::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/mutiny/mutants/mutant/location.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(position:, content:) ⇒ Location

Returns a new instance of Location.



7
8
9
10
11
12
# File 'lib/mutiny/mutants/mutant/location.rb', line 7

def initialize(position:, content:)
  position ||= {}
  @old_position = position[:old].freeze
  @new_position = position[:new].freeze
  @content = content
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



5
6
7
# File 'lib/mutiny/mutants/mutant/location.rb', line 5

def content
  @content
end

#new_positionObject (readonly)

Returns the value of attribute new_position.



5
6
7
# File 'lib/mutiny/mutants/mutant/location.rb', line 5

def new_position
  @new_position
end

#old_positionObject (readonly)

Returns the value of attribute old_position.



5
6
7
# File 'lib/mutiny/mutants/mutant/location.rb', line 5

def old_position
  @old_position
end

Instance Method Details

#linesObject



14
15
16
17
18
19
# File 'lib/mutiny/mutants/mutant/location.rb', line 14

def lines
  Range.new(
    line_number_of_offset(new_position.begin),
    line_number_of_offset(new_position.end)
  )
end