Sha256: a7de4399683a0b5f7fb428a0ddbb4576870b66c2d7ecdf3262ad51c3b5a12c3e

Contents?: true

Size: 589 Bytes

Versions: 3

Compression:

Stored size: 589 Bytes

Contents

module Differ
  module Format
    module Ascii
      class << self
        def format(change)
          (change.change? && as_change(change)) ||
          (change.delete? && as_delete(change)) ||
          (change.insert? && as_insert(change)) ||
          ''
        end

      private
        def as_insert(change)
          "{+#{change.insert.inspect}}"
        end

        def as_delete(change)
          "{-#{change.delete.inspect}}"
        end

        def as_change(change)
          "{#{change.delete.inspect} >> #{change.insert.inspect}}"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
pvande-differ-0.1.1 lib/differ/format/ascii.rb
differ-0.1.2 lib/differ/format/ascii.rb
differ-0.1.1 lib/differ/format/ascii.rb