Sha256: a0da716f9454cd90d48c413afd19b9dbcf6669c16b9b84ba7e7f808475084ac3

Contents?: true

Size: 514 Bytes

Versions: 2

Compression:

Stored size: 514 Bytes

Contents

module Flexite
  class DiffPresenter < SimpleDelegator
    def initialize(template, type, depth, _, *changes)
      @type = type
      @depth = depth
      @changes = changes
      super(template)
    end

    def to_view
      "PATH: #{@depth}\r#{t("labels.diff.operations.#{@type}") % prettified}"
    end

    private

    def prettified
      case @type.to_sym
        when :-, :+
          JSON.pretty_generate(@changes.first) rescue @changes.first
        else
          @changes
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flexite-0.0.18 app/presenters/flexite/diff_presenter.rb
flexite-0.0.17 app/presenters/flexite/diff_presenter.rb