Class: Card::Content::Diff::LCS::ExcludeeIterator
- Inherits:
-
Object
- Object
- Card::Content::Diff::LCS::ExcludeeIterator
- Defined in:
- lib/card/content/diff/l_c_s/processor.rb
Overview
support class for LCS::Processor
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(list) ⇒ ExcludeeIterator
constructor
A new instance of ExcludeeIterator.
- #next ⇒ Object
- #scan_and_record(record_array) ⇒ Object
- #word_step ⇒ Object
Constructor Details
#initialize(list) ⇒ ExcludeeIterator
Returns a new instance of ExcludeeIterator.
130 131 132 133 134 |
# File 'lib/card/content/diff/l_c_s/processor.rb', line 130 def initialize list @list = list @index = 0 @chunk_index = 0 end |
Class Method Details
.old_and_new(old_excludees, new_excludees) ⇒ Object
123 124 125 126 127 128 |
# File 'lib/card/content/diff/l_c_s/processor.rb', line 123 def self.old_and_new old_excludees, new_excludees { old: new(old_excludees), new: new(new_excludees) } end |
Instance Method Details
#next ⇒ Object
140 141 142 143 144 145 146 147 148 |
# File 'lib/card/content/diff/l_c_s/processor.rb', line 140 def next if @index < @list.size && @list[@index][:chunk_index] == @chunk_index res = @list[@index] @index += 1 @chunk_index += 1 res end end |
#scan_and_record(record_array) ⇒ Object
150 151 152 153 154 155 156 157 158 |
# File 'lib/card/content/diff/l_c_s/processor.rb', line 150 def scan_and_record record_array while (ex = self.next) if ex[:type] == :disjunction record_array << ex[:element] else yield ex[:element] end end end |
#word_step ⇒ Object
136 137 138 |
# File 'lib/card/content/diff/l_c_s/processor.rb', line 136 def word_step @chunk_index += 1 end |