class OCG::Operator::AND

OCG::Operator::AND class.

Public Instance Methods

finished?() click to toggle source

Is option combinations generation finished?

# File lib/ocg/operator/and.rb, line 36
def finished?
  @left_generator.finished? && @right_generator.finished?
end
last() click to toggle source

Get last option combination result.

# File lib/ocg/operator/and.rb, line 28
def last
  left  = @left_generator.last
  right = @right_generator.last

  merge_results left, right
end
length() click to toggle source

Get options combination length.

# File lib/ocg/operator/and.rb, line 46
def length
  left_length  = @left_generator.length
  right_length = @right_generator.length

  if left_length.zero?
    right_length
  elsif right_length.zero?
    left_length
  else
    left_length * right_length
  end
end
next() click to toggle source

Get next option combination result.

# File lib/ocg/operator/and.rb, line 11
def next
  return nil if finished?

  if @right_generator.finished?
    @right_generator.reset
    left = @left_generator.next
  else
    left = @left_generator.last
    left = @left_generator.next if left.nil?
  end

  right = @right_generator.next

  merge_results left, right
end
started?() click to toggle source

Is option combinations generation started?

# File lib/ocg/operator/and.rb, line 41
def started?
  @left_generator.started? || @right_generator.started?
end