Class: OCG::Operator::OR

Inherits:
Abstract show all
Defined in:
lib/ocg/operator/or.rb

Overview

OCG::Operator::OR class.

Constant Summary

Constants inherited from Abstract

Abstract::VARIABLES_TO_COPY

Constants inherited from OCG

DELEGATORS, VARIABLES_TO_COPY, VERSION

Constants included from Copyable

Copyable::VARIABLES_TO_COPY

Instance Method Summary collapse

Methods inherited from Abstract

#initialize, #reset

Methods inherited from OCG

#and, #each, #initialize, #mix, #or, prepare_generator

Methods included from Copyable

#initialize_copy

Constructor Details

This class inherits a constructor from OCG::Operator::Abstract

Instance Method Details

#finished?Boolean

Is option combinations generation finished?

Returns:

  • (Boolean)


39
40
41
# File 'lib/ocg/operator/or.rb', line 39

def finished?
  @left_generator.finished? && @right_generator.finished?
end

#lastObject

Get last option combination result.



22
23
24
25
26
27
28
29
30
31
# File 'lib/ocg/operator/or.rb', line 22

def last
  left  = @left_generator.last
  right = @right_generator.last

  if right.nil?
    left
  else
    right
  end
end

#lengthObject

Get option combinations length.



44
45
46
# File 'lib/ocg/operator/or.rb', line 44

def length
  @left_generator.length + @right_generator.length
end

#nextObject

Get next option combination result.



11
12
13
14
15
16
17
18
19
# File 'lib/ocg/operator/or.rb', line 11

def next
  return nil if finished?

  if @left_generator.finished?
    @right_generator.next
  else
    @left_generator.next
  end
end

#started?Boolean

Is option combinations generation started?

Returns:

  • (Boolean)


34
35
36
# File 'lib/ocg/operator/or.rb', line 34

def started?
  @left_generator.started? || @right_generator.started?
end