Class: DFuzz::Sequential

Inherits:
Generator
  • Object
show all
Defined in:
lib/dfuzz/sequential.rb

Instance Method Summary collapse

Methods inherited from Generator

#current, #each, #end?, #index, #next, #pos, #rewind, #yield

Constructor Details

#initialize(*generators) ⇒ Sequential

Returns a new instance of Sequential.



3
4
5
6
7
8
9
10
11
# File 'lib/dfuzz/sequential.rb', line 3

def initialize *generators
  super() do |g|
    generators.each do |gen|
      gen.each do |val|
        g.yield val
      end
    end
  end
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


24
# File 'lib/dfuzz/sequential.rb', line 24

def empty?; !self.next?; end

#next?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
# File 'lib/dfuzz/sequential.rb', line 13

def next?
  begin
    self.peek
    true
  rescue StopIteration
    false
  end
end

#shiftObject



23
# File 'lib/dfuzz/sequential.rb', line 23

def shift; next? ? self.next : nil; end

#to_aObject



22
# File 'lib/dfuzz/sequential.rb', line 22

def to_a; self; end