Class: Controller
Instance Attribute Summary collapse
-
#listener ⇒ Object
readonly
Returns the value of attribute listener.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#pwd_size ⇒ Object
readonly
Returns the value of attribute pwd_size.
-
#script ⇒ Object
readonly
Returns the value of attribute script.
-
#script_name ⇒ Object
readonly
Returns the value of attribute script_name.
Instance Method Summary collapse
Instance Attribute Details
#listener ⇒ Object (readonly)
Returns the value of attribute listener.
9 10 11 |
# File 'lib/controller.rb', line 9 def listener @listener end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/controller.rb', line 10 def end |
#pwd_size ⇒ Object (readonly)
Returns the value of attribute pwd_size.
11 12 13 |
# File 'lib/controller.rb', line 11 def pwd_size @pwd_size end |
#script ⇒ Object (readonly)
Returns the value of attribute script.
13 14 15 |
# File 'lib/controller.rb', line 13 def script @script end |
#script_name ⇒ Object (readonly)
Returns the value of attribute script_name.
12 13 14 |
# File 'lib/controller.rb', line 12 def script_name @script_name end |
Instance Method Details
#init(options, argv) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/controller.rb', line 15 def init(, argv) = @script_name = argv.first || ".watchr" @pwd_size = Dir.pwd.size if [:debug] puts "options #{@options}" puts "pwd <#{@pwd}>" puts "script_name <#{@script_name}>" end end |
#run ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/controller.rb', line 27 def run stop @script = Script.new @script.load_file(@script_name) @listener = Listen.to(".") do |modified, added, removed| run_files(modified, :modified) run_files(added, :added) end @listener.start sleep end |
#stop ⇒ Object
40 41 42 43 44 |
# File 'lib/controller.rb', line 40 def stop @listener&.stop @script = nil @listener = nil end |