Class: PrettyPrint::GroupQueue
- Defined in:
- lib/extensions/mspec/mspec/pp.rb
Instance Method Summary collapse
- #delete(group) ⇒ Object
- #deq ⇒ Object
- #enq(group) ⇒ Object
-
#initialize(*groups) ⇒ GroupQueue
constructor
A new instance of GroupQueue.
Constructor Details
#initialize(*groups) ⇒ GroupQueue
Returns a new instance of GroupQueue.
356 357 358 359 |
# File 'lib/extensions/mspec/mspec/pp.rb', line 356 def initialize(*groups) @queue = [] groups.each {|g| enq g} end |
Instance Method Details
#delete(group) ⇒ Object
382 383 384 |
# File 'lib/extensions/mspec/mspec/pp.rb', line 382 def delete(group) @queue[group.depth].delete(group) end |
#deq ⇒ Object
367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'lib/extensions/mspec/mspec/pp.rb', line 367 def deq @queue.each {|gs| (gs.length-1).downto(0) {|i| unless gs[i].breakables.empty? group = gs.slice!(i, 1).first group.break return group end } gs.each {|group| group.break} gs.clear } return nil end |
#enq(group) ⇒ Object
361 362 363 364 365 |
# File 'lib/extensions/mspec/mspec/pp.rb', line 361 def enq(group) depth = group.depth @queue << [] until depth < @queue.length @queue[depth] << group end |