Class: Pwrake::NoActionQueue
- Inherits:
-
Object
- Object
- Pwrake::NoActionQueue
- Defined in:
- lib/pwrake/queue/no_action_queue.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #empty? ⇒ Boolean
- #first ⇒ Object
-
#initialize ⇒ NoActionQueue
constructor
A new instance of NoActionQueue.
- #last ⇒ Object
- #length ⇒ Object (also: #size)
- #pop ⇒ Object (also: #shift, #deq)
- #push(obj) ⇒ Object (also: #<<, #enq)
Constructor Details
#initialize ⇒ NoActionQueue
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pwrake/queue/no_action_queue.rb', line 5 def initialize @que = [] prio = Rake.application.['NOACTION_QUEUE_PRIORITY'] || 'fifo' case prio when /fifo/i @prio = 0 Log.debug "NOACTION_QUEUE_PRIORITY=FIFO" when /lifo/i @prio = 1 Log.debug "NOACTION_QUEUE_PRIORITY=LIFO" when /rand/i @prio = 2 Log.debug "NOACTION_QUEUE_PRIORITY=RAND" else raise RuntimeError,"unknown option for NOACTION_QUEUE_PRIORITY: "+prio end end |
Instance Method Details
#clear ⇒ Object
49 50 51 |
# File 'lib/pwrake/queue/no_action_queue.rb', line 49 def clear @que.clear end |
#empty? ⇒ Boolean
45 46 47 |
# File 'lib/pwrake/queue/no_action_queue.rb', line 45 def empty? @que.empty? end |
#first ⇒ Object
58 59 60 |
# File 'lib/pwrake/queue/no_action_queue.rb', line 58 def first @que.first end |
#last ⇒ Object
62 63 64 |
# File 'lib/pwrake/queue/no_action_queue.rb', line 62 def last @que.last end |
#length ⇒ Object Also known as: size
53 54 55 |
# File 'lib/pwrake/queue/no_action_queue.rb', line 53 def length @que.length end |
#pop ⇒ Object Also known as: shift, deq
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pwrake/queue/no_action_queue.rb', line 30 def pop case @prio when 0 x = @que.shift when 1 x = @que.pop when 2 x = @que.delete_at(rand(@que.size)) end return x end |
#push(obj) ⇒ Object Also known as: <<, enq
23 24 25 |
# File 'lib/pwrake/queue/no_action_queue.rb', line 23 def push(obj) @que.push obj end |