Class: OCG::Operator::OR

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

Constant Summary

Constants inherited from OCG

DELEGATORS, VERSION

Instance Method Summary collapse

Methods inherited from Abstract

#initialize, #reset

Methods inherited from OCG

#and, #initialize, #mix, #or, prepare_generator, #to_a

Constructor Details

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

Instance Method Details

#finished?Boolean

Returns:

  • (Boolean)


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

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

#lastObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/ocg/operator/or.rb', line 19

def last
  left_last  = @left_generator.last
  right_last = @right_generator.last

  if right_last.nil?
    left_last
  else
    right_last
  end
end

#lengthObject



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

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

#nextObject



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

def next
  return nil if finished?

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

#started?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/ocg/operator/or.rb', line 30

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