Skip to content

Commit

Permalink
Mention in rdoc that Diff::LCS::ContextChange can be converted to an …
Browse files Browse the repository at this point in the history
…array
  • Loading branch information
knu authored and halostatue committed Jan 26, 2019
1 parent 01e0cae commit 3b4d2be
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/diff/lcs.rb
Expand Up @@ -181,6 +181,20 @@ def diff(seq1, seq2, callbacks = nil, &block) # :yields diff changes:
# 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)
Expand Down

0 comments on commit 3b4d2be

Please sign in to comment.