Class: Card::Content::Diff::LCS::ExcludeeIterator

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(list) ⇒ ExcludeeIterator

Returns a new instance of ExcludeeIterator.



132
133
134
135
136
# File 'lib/card/content/diff/l_c_s/processor.rb', line 132

def initialize list
  @list = list
  @index = 0
  @chunk_index = 0
end

Class Method Details

.old_and_new(old_excludees, new_excludees) ⇒ Object



125
126
127
128
129
130
# File 'lib/card/content/diff/l_c_s/processor.rb', line 125

def self.old_and_new old_excludees, new_excludees
  {
    old: new(old_excludees),
    new: new(new_excludees)
  }
end

Instance Method Details

#nextObject



142
143
144
145
146
147
148
149
150
# File 'lib/card/content/diff/l_c_s/processor.rb', line 142

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



152
153
154
155
156
157
158
159
160
# File 'lib/card/content/diff/l_c_s/processor.rb', line 152

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_stepObject



138
139
140
# File 'lib/card/content/diff/l_c_s/processor.rb', line 138

def word_step
  @chunk_index += 1
end