Class: Gotta::Mod::Listener
- Inherits:
-
Object
- Object
- Gotta::Mod::Listener
- Defined in:
- lib/gotta/mod/listener.rb
Instance Attribute Summary collapse
-
#listener ⇒ Object
readonly
Returns the value of attribute listener.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#working_directory ⇒ Object
readonly
Returns the value of attribute working_directory.
Instance Method Summary collapse
- #callback ⇒ Object
-
#initialize(working_directory:) ⇒ Listener
constructor
A new instance of Listener.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
Instance Attribute Details
#listener ⇒ Object (readonly)
Returns the value of attribute listener.
6 7 8 |
# File 'lib/gotta/mod/listener.rb', line 6 def listener @listener end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
6 7 8 |
# File 'lib/gotta/mod/listener.rb', line 6 def queue @queue end |
#working_directory ⇒ Object (readonly)
Returns the value of attribute working_directory.
6 7 8 |
# File 'lib/gotta/mod/listener.rb', line 6 def working_directory @working_directory end |
Instance Method Details
#callback ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/gotta/mod/listener.rb', line 21 def callback Proc.new do |modified, added, removed| begin modified.each do |file| queue.push Event.new(type: :modified, absolute_path: file, working_directory: working_directory) end added.each do |file| queue.push Event.new(type: :added, absolute_path: file, working_directory: working_directory) end removed.each do |file| queue.push Event.new(type: :removed, absolute_path: file, working_directory: working_directory) end rescue StandardError => e puts e. next end end end |
#start ⇒ Object
13 14 15 |
# File 'lib/gotta/mod/listener.rb', line 13 def start listener.start end |
#stop ⇒ Object
17 18 19 |
# File 'lib/gotta/mod/listener.rb', line 17 def stop listener.stop end |