class Milkode::WideMatcher

Attributes

num_max[R]

Public Class Methods

create(num_max) click to toggle source
# File lib/milkode/common/wide_matcher.rb, line 13
def self.create(num_max)
  if num_max == 0
    WideMatcherZero.new
  else
    WideMatcher.new(num_max)
  end
end
new(num_max) click to toggle source
# File lib/milkode/common/wide_matcher.rb, line 21
def initialize(num_max)
  @num_max   = num_max
  @container = []
end

Public Instance Methods

add_line_matchs(index, matches) click to toggle source
# File lib/milkode/common/wide_matcher.rb, line 30
def add_line_matchs(index, matches)
  @last_index = index
  @container.shift if linenum >= @num_max
  @container << matches
  # p @container
end
linenum() click to toggle source
# File lib/milkode/common/wide_matcher.rb, line 26
def linenum
  @container.size
end
match?() click to toggle source
# File lib/milkode/common/wide_matcher.rb, line 37
def match?
  @container.reduce(Array.new(@container.first.size)) {|result, matches|
    matches.each_with_index do |m, i|
      result[i] |= m
    end
    result
  }.all?
end
match_lines() click to toggle source
# File lib/milkode/common/wide_matcher.rb, line 46
def match_lines
  index = @last_index - @container.size + 1
  @container.reduce([]) do |result, matches|
    m = matches.compact
    result << MatchLineResult.new(index, m) unless m.empty?
    index += 1
    result
  end
end