Sha256: f1c1d87f488ed0ab97650674822a80db41a23e8b1ce66ce08c7e03dc94c1dbb1

Contents?: true

Size: 604 Bytes

Versions: 3

Compression:

Stored size: 604 Bytes

Contents

module Differ
  module Format
    module HTML
      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)
          %Q{<ins class="differ">#{change.insert}</ins>}
        end

        def as_delete(change)
          %Q{<del class="differ">#{change.delete}</del>}
        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/html.rb
differ-0.1.2 lib/differ/format/html.rb
differ-0.1.1 lib/differ/format/html.rb