Sha256: 2205a42e14f8483427724b491113df7e74d9d64bb77348331fae4114c838fa40

Contents?: true

Size: 577 Bytes

Versions: 1

Compression:

Stored size: 577 Bytes

Contents

module Differ
  module Format
    module Color
      class << self
        def call(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

1 entries across 1 versions & 1 rubygems

Version Path
ninja-differ-1.0.0 lib/differ/format/color.rb