Class: Uh::WM::ActionHandler
- Inherits:
-
Object
- Object
- Uh::WM::ActionHandler
show all
- Defined in:
- lib/uh/wm/action_handler.rb
Instance Method Summary
collapse
Constructor Details
#initialize(wm, manager, layout) ⇒ ActionHandler
Returns a new instance of ActionHandler.
4
5
6
|
# File 'lib/uh/wm/action_handler.rb', line 4
def initialize(wm, manager, layout)
@wm, @manager, @layout = wm, manager, layout
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/uh/wm/action_handler.rb', line 37
def method_missing(m, *args, &block)
if respond_to? m
meth = layout_method m
@wm.log "#{@layout.class.name}##{meth} #{args.inspect}"
@layout.send(meth, *args)
else
super
end
end
|
Instance Method Details
#call(action) ⇒ Object
8
9
10
|
# File 'lib/uh/wm/action_handler.rb', line 8
def call(action)
instance_exec &action
end
|
#execute(command) ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/uh/wm/action_handler.rb', line 17
def execute(command)
@wm.log "Spawn `#{command}`"
pid = spawn command, pgroup: true
Process.detach pid
rescue Errno::ENOENT => e
@wm.log_error "Spawn: #{e}"
end
|
#log_clients ⇒ Object
29
30
31
|
# File 'lib/uh/wm/action_handler.rb', line 29
def log_clients
@wm.log "Clients:\n#{@manager.to_s.lines.map { |e| " #{e}" }.join.chomp}"
end
|
#log_layout ⇒ Object
25
26
27
|
# File 'lib/uh/wm/action_handler.rb', line 25
def log_layout
@wm.log "Layout:\n#{@layout.to_s.lines.map { |e| " #{e}" }.join.chomp}"
end
|
#log_separator ⇒ Object
33
34
35
|
# File 'lib/uh/wm/action_handler.rb', line 33
def log_separator
@wm.log '- ' * 24
end
|
#quit ⇒ Object
12
13
14
15
|
# File 'lib/uh/wm/action_handler.rb', line 12
def quit
@wm.log 'Exiting...'
@wm.request_quit!
end
|
#respond_to_missing?(m) ⇒ Boolean
47
48
49
|
# File 'lib/uh/wm/action_handler.rb', line 47
def respond_to_missing?(m, *)
m.to_s =~ /\Alayout_/ || super
end
|