Sha256: 3a8035b7e24ec1e661d2ccb3557bbc61d6ce1f938205adf37190e8e1062ebac9

Contents?: true

Size: 761 Bytes

Versions: 2027

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true

# A block is an operation removing, adding, or changing a group of items.
# Basically, this is just a list of changes, where each change adds or
# deletes a single item. Used by bin/ldiff.
class Diff::LCS::Block
  attr_reader :changes, :insert, :remove

  def initialize(chunk)
    @changes = []
    @insert = []
    @remove = []

    chunk.each do |item|
      @changes << item
      @remove << item if item.deleting?
      @insert << item if item.adding?
    end
  end

  def diff_size
    @insert.size - @remove.size
  end

  def op
    case [@remove.empty?, @insert.empty?]
    when [false, false]
      "!"
    when [false, true]
      "-"
    when [true, false]
      "+"
    else # [true, true]
      "^"
    end
  end
end

Version data entries

2,027 entries across 2,027 versions & 16 rubygems

Version Path
cybrid_api_id_ruby-0.123.132 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_organization_ruby-0.123.132 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_bank_ruby-0.123.131 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_id_ruby-0.123.131 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_organization_ruby-0.123.131 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_bank_ruby-0.123.129 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_id_ruby-0.123.129 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_organization_ruby-0.123.129 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_bank_ruby-0.123.127 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_id_ruby-0.123.127 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_organization_ruby-0.123.127 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_bank_ruby-0.123.126 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_id_ruby-0.123.126 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_organization_ruby-0.123.126 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_bank_ruby-0.123.125 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_organization_ruby-0.123.125 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_id_ruby-0.123.125 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_bank_ruby-0.123.124 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_organization_ruby-0.123.124 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb
cybrid_api_id_ruby-0.123.124 vendor/bundle/ruby/3.3.0/gems/diff-lcs-1.5.1/lib/diff/lcs/block.rb