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
Returns a new instance of 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
48 49 50 |
# File 'lib/pwrake/queue/no_action_queue.rb', line 48 def clear @que.clear end |
#empty? ⇒ Boolean
44 45 46 |
# File 'lib/pwrake/queue/no_action_queue.rb', line 44 def empty? @que.empty? end |
#first ⇒ Object
57 58 59 |
# File 'lib/pwrake/queue/no_action_queue.rb', line 57 def first @que.first end |
#last ⇒ Object
61 62 63 |
# File 'lib/pwrake/queue/no_action_queue.rb', line 61 def last @que.last end |
#length ⇒ Object Also known as: size
52 53 54 |
# File 'lib/pwrake/queue/no_action_queue.rb', line 52 def length @que.length end |
#pop ⇒ Object Also known as: shift, deq
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pwrake/queue/no_action_queue.rb', line 30 def pop case @prio when 0 @que.shift when 1 @que.pop when 2 @que.delete_at(rand(@que.size)) end 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 |