diff options
author | Jon Rowe <hello@jonrowe.co.uk> | 2013-03-15 12:41:34 +1100 |
---|---|---|
committer | Jon Rowe <hello@jonrowe.co.uk> | 2013-03-15 12:41:34 +1100 |
commit | f1ed23f07f01fd3bee9d34686e030595399b0b30 (patch) | |
tree | 8818cd1803a9c2d1d58ae061aa9266bbe79f2da8 | |
parent | 58c2f6b8f551e0eca4b8958d3460f23aa9a611d1 (diff) | |
download | diff-lcs-f1ed23f07f01fd3bee9d34686e030595399b0b30.tar.gz |
ruby 187... support...
-rw-r--r-- | lib/diff/lcs/hunk.rb | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/diff/lcs/hunk.rb b/lib/diff/lcs/hunk.rb index abdd5bf..ba73415 100644 --- a/lib/diff/lcs/hunk.rb +++ b/lib/diff/lcs/hunk.rb @@ -250,14 +250,24 @@ class Diff::LCS::Hunk end private :unified_range - def encode(literal) - literal.encode @data_old[0].encoding - end - private :encode + if String.method_defined?(:encoding) + def encode(literal) + literal.encode @data_old[0].encoding + end - def encode_to(string, args) - args.map { |arg| arg.encode(string.encoding) } + def encode_to(string, args) + args.map { |arg| arg.encode(string.encoding) } + end + else + def encode(literal) + literal + end + def encode_to(string, args) + args + end end + + private :encode private :encode_to def match_encoding_gsub(string, *args, &block) |