Skip to content

Commit

Permalink
Update usage with return values
Browse files Browse the repository at this point in the history
  • Loading branch information
ezkl committed Jun 3, 2020
1 parent 24e2c87 commit 12503fa
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,32 @@
## Usage
```ruby
require 'dimapa'
dmp = DiMaPa.new

dmp = DiMaPa.new # or DiffMatchPatch

diff = dmp.diff_main("This is a sentence.", "This is also a sentence.")
#=> [[:equal, "This is a"], [:insert, "lso a"], [:equal, " sentence."]]

dmp.diff_cleanup_semantic(diff)
#=> nil

# diff is modified in place
diff
#=> [[:equal, "This is "], [:insert, "also "], [:equal, "a sentence."]]

patch = dmp.patch_make(diff)
#=> [#<PatchObj:0x00005608e6ac9500 @diffs=
# [[:equal, "This is "], [:insert, "also "], [:equal, "a senten"]],
# @length1=16,
# @length2=21,
# @start1=0,
# @start2=0>]

dmp.patch_to_text(patch)
#=> "@@ -1,16 +1,21 @@\n This is \n+also \n a senten\n"

dmp.patch_apply(patch, "This is a sentence.")
#=> ["This is also a sentence.", [true]]
```

A ruby implementation of the google diff-match-patch library.
Expand Down

0 comments on commit 12503fa

Please # to comment.