Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #to_ary to Diff::LCS::Change and Diff::LCS::ContextChange #47

Merged
merged 2 commits into from Jan 26, 2019
Merged

Conversation

knu
Copy link
Contributor

@knu knu commented Jan 24, 2019

It would be quite handy if you could write as follows:

Diff::LCS.sdiff(a, b).each do |action, (old_position, old_element), (new_position, new_element)|
  case action
  when '!'
    # replace
  when '-'
    # delete
  when '+'
    # insert
  end
end

It would be quite handy if you could write as follows:

```ruby
Diff::LCS.sdiff(a, b).each do |action, (old_position, old_element), (new_position, new_element)|
  case action
  when '!'
    # replace
  when '-'
    # delete
  when '+'
    # insert
  end
end
```
@halostatue
Copy link
Owner

Simple but effective. Can I ask that you add a little documentation for this particular use-case? I can see my way to making a release on the weekend.

@knu
Copy link
Contributor Author

knu commented Jan 26, 2019

@halostatue I added a paragraph to the rdoc of Diff::LCS.sdiff. Feel free to correct it as necessary!

@halostatue halostatue merged commit 3b4d2be into halostatue:master Jan 26, 2019
@halostatue
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants