Class: Listen::Event::Queue

Inherits:
Object
  • Object
show all
Defined in:
lib/listen/event/queue.rb

Defined Under Namespace

Classes: Config

Instance Method Summary collapse

Constructor Details

#initialize(config, &block) ⇒ Queue

Returns a new instance of Queue.



16
17
18
19
20
# File 'lib/listen/event/queue.rb', line 16

def initialize(config, &block)
  @event_queue = ::Queue.new
  @block = block
  @config = config
end

Instance Method Details

#<<(args) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/listen/event/queue.rb', line 22

def <<(args)
  type, change, dir, path, options = *args
  fail "Invalid type: #{type.inspect}" unless [:dir, :file].include? type
  fail "Invalid change: #{change.inspect}" unless change.is_a?(Symbol)
  fail "Invalid path: #{path.inspect}" unless path.is_a?(String)

  dir = _safe_relative_from_cwd(dir)
  event_queue.public_send(:<<, [type, change, dir, path, options])

  block.call(args) if block
end

#empty?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/listen/event/queue.rb', line 34

def empty?
  event_queue.empty?
end

#popObject



38
39
40
# File 'lib/listen/event/queue.rb', line 38

def pop
  event_queue.pop
end