Class: SeeingIsBelieving::Queue::While

Inherits:
Object
  • Object
show all
Defined in:
lib/seeing_is_believing/queue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue, &conditional) ⇒ While

Returns a new instance of While.



6
7
8
# File 'lib/seeing_is_believing/queue.rb', line 6

def initialize(queue, &conditional)
  self.queue, self.conditional = queue, conditional
end

Instance Attribute Details

#conditionalObject

Returns the value of attribute conditional.



4
5
6
# File 'lib/seeing_is_believing/queue.rb', line 4

def conditional
  @conditional
end

#queueObject

Returns the value of attribute queue.



4
5
6
# File 'lib/seeing_is_believing/queue.rb', line 4

def queue
  @queue
end

Instance Method Details

#each(&block) ⇒ Object



10
11
12
# File 'lib/seeing_is_believing/queue.rb', line 10

def each(&block)
  block.call queue.dequeue while !queue.empty? && conditional.call(queue.peek)
end