class Mutiny::Mutants::Mutant::Location

Attributes

content[R]
new_position[R]
old_position[R]

Public Class Methods

new(position:, content:) click to toggle source
# 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

Public Instance Methods

lines() click to toggle source
# 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

Private Instance Methods

line_number_of_offset(offset) click to toggle source
# File lib/mutiny/mutants/mutant/location.rb, line 23
def line_number_of_offset(offset)
  content[0..offset].lines.size
end