46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/aud/cli.rb', line 46
def listen
case options[:strategy]
when 'test'
return [nil, options]
when 'tick'
_exit = false
Signal.trap(:INT) do _exit = true end
Signal.trap(:TERM) do _exit = true end
output = UniMIDI::Output.first
aud = Aud::Tick.new(output, options)
process_line = lambda { |line|
line = line.strip
aud.process(line)
puts line unless options[:silent]
sleep(options[:delay] / 1000.0)
}
if options[:file]
File.open(options[:file]).each do |line|
process_line.call(line) unless _exit
end
else
ARGV.clear
ARGF.each_line do |line|
process_line.call(line) unless _exit
end
end
else
raise 'Only tick strategy is supported, but feel free to contribute another!'
end
end
|