Class: OCG::Operator::AND
- Defined in:
- lib/ocg/operator/and.rb
Overview
OCG::Operator::AND class.
Constant Summary
Constants inherited from Abstract
OCG::Operator::Abstract::VARIABLES_TO_COPY
Constants inherited from OCG
DELEGATORS, VARIABLES_TO_COPY, VERSION
Constants included from Copyable
Instance Method Summary collapse
-
#finished? ⇒ Boolean
Is option combinations generation finished?.
-
#last ⇒ Object
Get last option combination result.
-
#length ⇒ Object
Get options combination length.
-
#next ⇒ Object
Get next option combination result.
-
#started? ⇒ Boolean
Is option combinations generation started?.
Methods inherited from Abstract
Methods inherited from OCG
#and, #each, #initialize, #mix, #or, prepare_generator
Methods included from Copyable
Constructor Details
This class inherits a constructor from OCG::Operator::Abstract
Instance Method Details
#finished? ⇒ Boolean
Is option combinations generation finished?
36 37 38 |
# File 'lib/ocg/operator/and.rb', line 36 def finished? @left_generator.finished? && @right_generator.finished? end |
#last ⇒ Object
Get last option combination result.
28 29 30 31 32 33 |
# File 'lib/ocg/operator/and.rb', line 28 def last left = @left_generator.last right = @right_generator.last merge_results left, right end |
#length ⇒ Object
Get options combination length.
46 47 48 49 50 51 52 53 54 55 56 57 |
# 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 ⇒ Object
Get next option combination result.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# 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? ⇒ Boolean
Is option combinations generation started?
41 42 43 |
# File 'lib/ocg/operator/and.rb', line 41 def started? @left_generator.started? || @right_generator.started? end |