class Ducalis::Patch
Constants
- ANY_LINE
- DIFF_LINES
- MODIFIED_LINE
- NOT_REMOVED_LINE
- RANGE_LINE
Attributes
patch_lines[R]
Public Class Methods
new(patch)
click to toggle source
# File lib/ducalis/patch.rb, line 25 def initialize(patch) diff_only = patch[patch.match(RANGE_LINE).begin(0)..-1] @patch_lines = diff_only.lines.to_enum.with_index end
Public Instance Methods
line_for(line_number)
click to toggle source
# File lib/ducalis/patch.rb, line 30 def line_for(line_number) changed_lines.detect do |line| line.number == line_number end || UnchangedLine.new end
Private Instance Methods
changed_lines()
click to toggle source
# File lib/ducalis/patch.rb, line 40 def changed_lines patch_lines.inject([[], 0]) do |(lines, line_number), (line, position)| _regex, action = DIFF_LINES.find { |regex, _action| line =~ regex } action.call(lines, line_number, line, position) end.first end