Class: Canopus::Patch::Reload

Inherits:
Object
  • Object
show all
Defined in:
lib/canopus/patch/reload.rb,
sig/canopus.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(before, after) ⇒ Reload

Returns a new instance of Reload.

Parameters:

  • before (rope)
  • after (rope)


5
# File 'lib/canopus/patch/reload.rb', line 5

def initialize(before, after) = (@before, @after = before, after)

Instance Attribute Details

#after ⇒ rope (readonly)

Returns the value of attribute after.

Returns:

  • (rope)


4
5
6
# File 'lib/canopus/patch/reload.rb', line 4

def after
  @after
end

#before ⇒ rope (readonly)

Returns the value of attribute before.

Returns:

  • (rope)


4
5
6
# File 'lib/canopus/patch/reload.rb', line 4

def before
  @before
end

Instance Method Details

#edits ⇒ Array[Edit]

Returns:



6
# File 'lib/canopus/patch/reload.rb', line 6

def edits = []

#map_offset(offset, bias: :right) ⇒ Integer

Parameters:

  • offset (Integer)
  • bias: (bias) (defaults to: :right)

Returns:

  • (Integer)


7
8
9
10
11
12
13
14
15
16
17
# File 'lib/canopus/patch/reload.rb', line 7

def map_offset(offset, bias: :right)
  position = offset.clamp(0, after.bytesize)
  begin
    after.point_at(position)
    position
  rescue RangeError
    position -= 1
    retry if position >= 0
    raise
  end
end