Class: OCG::Operator::MIX
Constant Summary
Constants inherited
from OCG
DELEGATORS, VERSION
Instance Method Summary
collapse
Methods inherited from Abstract
#reset
Methods inherited from OCG
#and, #mix, #or, prepare_generator, #to_a
Constructor Details
#initialize(*args) ⇒ MIX
Returns a new instance of MIX.
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/ocg/operator/mix.rb', line 9
def initialize(*args)
super
@main_generator = \
if @right_generator.length > @left_generator.length
@right_generator
else
@left_generator
end
end
|
Instance Method Details
#finished? ⇒ Boolean
41
42
43
|
# File 'lib/ocg/operator/mix.rb', line 41
def finished?
@main_generator.finished?
end
|
#last ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/ocg/operator/mix.rb', line 28
def last
left_last = @left_generator.last
right_last = @right_generator.last
return nil if left_last.nil? || right_last.nil?
left_last.merge right_last
end
|
#length ⇒ Object
45
46
47
|
# File 'lib/ocg/operator/mix.rb', line 45
def length
@main_generator.length
end
|
#next ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/ocg/operator/mix.rb', line 20
def next
return nil if finished?
@left_generator.reset if @left_generator.finished?
@right_generator.reset if @right_generator.finished?
@left_generator.next.merge @right_generator.next
end
|
#started? ⇒ Boolean
37
38
39
|
# File 'lib/ocg/operator/mix.rb', line 37
def started?
@main_generator.started?
end
|