summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAkinori MUSHA <knu@idaemons.org>2019-01-25 19:08:55 +0900
committerAustin Ziegler <austin@zieglers.ca>2019-01-26 00:40:04 -0500
commit3b4d2be9c32041ebc2a567dcd6518c6fcf9908a8 (patch)
treeb421de77fe6edfb177279a22ac27d95021753ad6 /lib
parent01e0caeda9ae38b7868f35987844fd9f67aef005 (diff)
downloaddiff-lcs-3b4d2be9c32041ebc2a567dcd6518c6fcf9908a8.tar.gz
Mention in rdoc that Diff::LCS::ContextChange can be converted to an array
Diffstat (limited to 'lib')
-rw-r--r--lib/diff/lcs.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/diff/lcs.rb b/lib/diff/lcs.rb
index 34ddf0f..8fb4314 100644
--- a/lib/diff/lcs.rb
+++ b/lib/diff/lcs.rb
@@ -181,6 +181,20 @@ class << Diff::LCS
# Class argument is provided for +callbacks+, #diff will attempt to
# initialise it. If the +callbacks+ object (possibly initialised) responds
# to #finish, it will be called.
+ #
+ # Each element of a returned array is a Diff::LCS::ContextChange object,
+ # which can be implicitly converted to an array.
+ #
+ # Diff::LCS.sdiff(a, b).each do |action, (old_pos, old_element), (new_pos, new_element)|
+ # case action
+ # when '!'
+ # # replace
+ # when '-'
+ # # delete
+ # when '+'
+ # # insert
+ # end
+ # end
def sdiff(seq1, seq2, callbacks = nil, &block) #:yields diff changes:
diff_traversal(:sdiff, seq1, seq2, callbacks || Diff::LCS::SDiffCallbacks,
&block)