summaryrefslogtreecommitdiff
path: root/lib/diff/lcs/callbacks.rb
diff options
context:
space:
mode:
authorAustin Ziegler <austin@zieglers.ca>2019-01-27 00:15:29 -0500
committerAustin Ziegler <austin@zieglers.ca>2019-01-27 23:26:05 -0500
commit45ea1b30c7de0ad840f72afb82fd41eb2b9590db (patch)
tree22f879cbd21a183bac5c17f754c0aa598531d968 /lib/diff/lcs/callbacks.rb
parent07ed577eba341f0ff0d7eebf4c1c2cc23083cba7 (diff)
downloaddiff-lcs-45ea1b30c7de0ad840f72afb82fd41eb2b9590db.tar.gz
Applied Rubocop rules that I like
- Other linting configuration also applied. - Soft-deprecating versions older than 2.3.
Diffstat (limited to 'lib/diff/lcs/callbacks.rb')
-rw-r--r--lib/diff/lcs/callbacks.rb23
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/diff/lcs/callbacks.rb b/lib/diff/lcs/callbacks.rb
index 8eec5fc..93c860d 100644
--- a/lib/diff/lcs/callbacks.rb
+++ b/lib/diff/lcs/callbacks.rb
@@ -1,8 +1,8 @@
-# -*- ruby encoding: utf-8 -*-
+# frozen_string_literal: true
require 'diff/lcs/change'
-module Diff::LCS
+module Diff::LCS # rubocop:disable Style/Documentation
# This callback object implements the default set of callback events,
# which only returns the event itself. Note that #finished_a and
# #finished_b are not implemented -- I haven't yet figured out where they
@@ -17,14 +17,17 @@ module Diff::LCS
def match(event)
event
end
+
# Called when the old value is discarded in favour of the new value.
def discard_a(event)
event
end
+
# Called when the new value is discarded in favour of the old value.
def discard_b(event)
event
end
+
# Called when both the old and new values have changed.
def change(event)
event
@@ -108,12 +111,12 @@ class Diff::LCS::DiffCallbacks
@hunk = []
@diffs = []
- if block_given?
- begin
- yield self
- ensure
- self.finish
- end
+ return unless block_given?
+
+ begin
+ yield self
+ ensure
+ finish
end
end
@@ -123,7 +126,7 @@ class Diff::LCS::DiffCallbacks
finish_hunk
end
- def match(event)
+ def match(_event)
finish_hunk
end
@@ -241,7 +244,7 @@ end
# will compute and display the necessary components to show two sequences
# and their minimized differences side by side, just like the Unix utility
# +sdiff+.
-#
+#
# same same
# before | after
# old < -