Class: SeeingIsBelieving::Queue::While
- Inherits:
-
Object
- Object
- SeeingIsBelieving::Queue::While
- Defined in:
- lib/seeing_is_believing/queue.rb
Instance Attribute Summary collapse
-
#conditional ⇒ Object
Returns the value of attribute conditional.
-
#queue ⇒ Object
Returns the value of attribute queue.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(queue, &conditional) ⇒ While
constructor
A new instance of While.
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
#conditional ⇒ Object
Returns the value of attribute conditional.
4 5 6 |
# File 'lib/seeing_is_believing/queue.rb', line 4 def conditional @conditional end |
#queue ⇒ Object
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 |