Class: Pwrake::NoActionQueue

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

Instance Method Summary collapse

Constructor Details

#initializeNoActionQueue

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.pwrake_options['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

#clearObject



48
49
50
# File 'lib/pwrake/queue/no_action_queue.rb', line 48

def clear
  @que.clear
end

#empty?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/pwrake/queue/no_action_queue.rb', line 44

def empty?
  @que.empty?
end

#firstObject



57
58
59
# File 'lib/pwrake/queue/no_action_queue.rb', line 57

def first
  @que.first
end

#lastObject



61
62
63
# File 'lib/pwrake/queue/no_action_queue.rb', line 61

def last
  @que.last
end

#lengthObject Also known as: size



52
53
54
# File 'lib/pwrake/queue/no_action_queue.rb', line 52

def length
  @que.length
end

#popObject 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