Class: Diff::LCS::Block
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb
Overview
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.
Instance Attribute Summary collapse
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
-
#insert ⇒ Object
readonly
Returns the value of attribute insert.
-
#remove ⇒ Object
readonly
Returns the value of attribute remove.
Instance Method Summary collapse
- #diff_size ⇒ Object
-
#initialize(chunk) ⇒ Block
constructor
A new instance of Block.
- #op ⇒ Object
Constructor Details
#initialize(chunk) ⇒ Block
Returns a new instance of Block.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb', line 9 def initialize(chunk) @changes = [] @insert = [] @remove = [] chunk.each do |item| @changes << item @remove << item if item.deleting? @insert << item if item.adding? end end |
Instance Attribute Details
#changes ⇒ Object (readonly)
Returns the value of attribute changes.
7 8 9 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb', line 7 def changes @changes end |
#insert ⇒ Object (readonly)
Returns the value of attribute insert.
7 8 9 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb', line 7 def insert @insert end |
#remove ⇒ Object (readonly)
Returns the value of attribute remove.
7 8 9 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb', line 7 def remove @remove end |
Instance Method Details
#diff_size ⇒ Object
21 22 23 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb', line 21 def diff_size @insert.size - @remove.size end |
#op ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/diff-lcs-1.5.0/lib/diff/lcs/block.rb', line 25 def op case [@remove.empty?, @insert.empty?] when [false, false] '!' when [false, true] '-' when [true, false] '+' else # [true, true] '^' end end |