Method: TextAlignment::TextAlignment#transform_end_position

Defined in:
lib/text_alignment/text_alignment.rb

#transform_end_position(_end_position) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/text_alignment/text_alignment.rb', line 76

def transform_end_position(_end_position)
	end_position = @text_mapping.enmap_position(_end_position)

	i = @blocks.index{|b| b[:source][:end] >= end_position}
	block = @blocks[i]

	e = if block[:alignment] == :block || block[:alignment] == :term
		end_position + block[:delta]
	elsif block[:alignment] == :empty
		if end_position == block[:source][:end]
			block[:target][:end]
		else
			nil
		end
	else
		r = block[:alignment].transform_end_position(end_position - block[:source][:begin])
		r.nil? ? nil : r + block[:target][:begin]
	end

	@rtext_mapping.demap_position(e)
end