diff options
author | Jon Rowe <hello@jonrowe.co.uk> | 2013-03-15 12:44:16 +1100 |
---|---|---|
committer | Jon Rowe <hello@jonrowe.co.uk> | 2013-03-15 12:44:16 +1100 |
commit | c977dfc8017f03f8fa70351b5ddedad9ad88fa4d (patch) | |
tree | 0eb151ac7a34fb5f616b54949b96ce648e573d6c | |
parent | f1ed23f07f01fd3bee9d34686e030595399b0b30 (diff) | |
download | diff-lcs-c977dfc8017f03f8fa70351b5ddedad9ad88fa4d.tar.gz |
refactor out encoding method
-rw-r--r-- | lib/diff/lcs/hunk.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/diff/lcs/hunk.rb b/lib/diff/lcs/hunk.rb index ba73415..bcd85d5 100644 --- a/lib/diff/lcs/hunk.rb +++ b/lib/diff/lcs/hunk.rb @@ -11,6 +11,7 @@ class Diff::LCS::Hunk def initialize(data_old, data_new, piece, flag_context, file_length_difference) # At first, a hunk will have just one Block in it @blocks = [ Diff::LCS::Block.new(piece) ] + @preferred_data_encoding = data_old[0].encoding if String.method_defined?(:encoding) @data_old = data_old @data_new = data_new @@ -252,7 +253,7 @@ class Diff::LCS::Hunk if String.method_defined?(:encoding) def encode(literal) - literal.encode @data_old[0].encoding + literal.encode @preferred_data_encoding end def encode_to(string, args) |