Sha256: 8a28799c3cdb53c1659f0d91e33efab31c0745a2cf5d631fa2b76a5fefe830b4

Contents?: true

Size: 694 Bytes

Versions: 2

Compression:

Stored size: 694 Bytes

Contents

::Specdiff::Diff = Struct.new(
  :differ, :a, :b, :raw, keyword_init: true,
) do
  def differ_id
    differ.id
  end

  def to_s
    differ.stringify(self)
  end

  def empty?
    differ == ::Specdiff::Differ::NotFound ||
      (differ.respond_to?(:empty?) && differ.empty?(self))
  end

  def types
    [a.type, b.type]
  end

  def inspect
    raw_diff = if empty?
                 "empty"
               elsif differ == ::Specdiff::Differ::Text
                 bytes = raw&.bytesize || 0
                 "#{bytes} bytes of #raw diff"
               else
                 "#{raw.inspect}"
               end

    "<Specdiff::Diff (#{a.type}/#{b.type}) (#{differ}) (#{raw_diff})>"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
specdiff-0.3.0 lib/specdiff/diff.rb
specdiff-0.3.0.rc2 lib/specdiff/diff.rb