Class: Listen::Event::Queue
- Inherits:
-
Object
- Object
- Listen::Event::Queue
- Defined in:
- lib/listen/event/queue.rb
Defined Under Namespace
Classes: Config
Instance Method Summary collapse
- #<<(args) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(config, &block) ⇒ Queue
constructor
A new instance of Queue.
- #pop ⇒ Object
Constructor Details
#initialize(config, &block) ⇒ Queue
Returns a new instance of Queue.
14 15 16 17 18 |
# File 'lib/listen/event/queue.rb', line 14 def initialize(config, &block) @event_queue = Thread::Queue.new @block = block @config = config end |
Instance Method Details
#<<(args) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/listen/event/queue.rb', line 20 def <<(args) type, change, dir, path, = *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, ]) block.call(args) if block end |
#empty? ⇒ Boolean
32 33 34 |
# File 'lib/listen/event/queue.rb', line 32 def empty? event_queue.empty? end |
#pop ⇒ Object
36 37 38 |
# File 'lib/listen/event/queue.rb', line 36 def pop event_queue.pop end |