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



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

def clear
  @que.clear
end

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  @que.empty?
end

#firstObject



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

def first
  @que.first
end

#lastObject



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

def last
  @que.last
end

#lengthObject Also known as: size



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

def length
  @que.length
end

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