Sha256: c2ba06b2ba1c23a8d3f5390e1500bf6e5303efbf50f1f8a1571334e54ce349d5

Contents?: true

Size: 579 Bytes

Versions: 3

Compression:

Stored size: 579 Bytes

Contents

module Differ
  module Format
    module Color
      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)
          "\033[32m#{change.insert}\033[0m"
        end

        def as_delete(change)
          "\033[31m#{change.delete}\033[0m"
        end

        def as_change(change)
          as_delete(change) << as_insert(change)
        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/color.rb
differ-0.1.2 lib/differ/format/color.rb
differ-0.1.1 lib/differ/format/color.rb