Class: Fusuma::Plugin::Inputs::TimerInput
- Inherits:
-
Input
- Object
- Base
- Input
- Fusuma::Plugin::Inputs::TimerInput
show all
- Defined in:
- lib/fusuma/plugin/inputs/timer_input.rb
Overview
libinput commands wrapper
Constant Summary
collapse
- DEFAULT_INTERVAL =
0.3
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Input
#create_event, select, #tag
Methods inherited from Base
#config_index, #config_params, inherited, plugins
#fork
Instance Attribute Details
#pid ⇒ Object
Returns the value of attribute pid.
17
18
19
|
# File 'lib/fusuma/plugin/inputs/timer_input.rb', line 17
def pid
@pid
end
|
Instance Method Details
#config_param_types ⇒ Object
11
12
13
14
15
|
# File 'lib/fusuma/plugin/inputs/timer_input.rb', line 11
def config_param_types
{
interval: [Float]
}
end
|
#io ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/fusuma/plugin/inputs/timer_input.rb', line 19
def io
@io ||= begin
reader, writer = create_io
@pid = start(reader, writer)
reader
end
end
|
#start(reader, writer) ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/fusuma/plugin/inputs/timer_input.rb', line 28
def start(reader, writer)
pid = fork do
timer_loop(reader, writer)
end
Process.detach(pid)
writer.close
pid
end
|
#timer_loop(reader, writer) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/fusuma/plugin/inputs/timer_input.rb', line 37
def timer_loop(reader, writer)
reader.close
begin
loop do
sleep interval
writer.puts 'timer'
end
rescue Errno::EPIPE
exit 0
rescue StandardError => e
MultiLogger.error e
end
end
|