4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/euclidean_sequencer/parser.rb', line 4
def self.parse(argv)
options = Struct.new(:hits, :pulses, :array, :offset)
args = options.new()
opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: euclidean_sequncer [options]"
opts.on("-h", "--hits=HITS", Integer, "Number of 'on' elements in the sequncer: INTEGER") do |hits|
args.hits = hits
end
opts.on("-pPULSES", "--pulses=PULSES", Integer, "Total number of elements in the sequncer: INTEGER") do |pulses|
raise Exception if pulses.nil?
args.pulses = pulses
end
opts.on("-a", "--array=TRUE", FalseClass, "Output as array (optional): BOOLEAN") do |array|
args.array = array
end
opts.on("-o", "--offset=OFFSET", Integer, "Number elements left shifted in the sequence (optional): INTEGER") do |offset|
args.offset = offset
end
opts.on("-?", "--help", "Prints this help") do
puts opts
exit
end
end
begin
opt_parser.parse!(argv)
rescue Exception => error
printf("ERROR: %s \n", error)
opt_parser.parse!(["--help"])
exit 1
end
return args
end
|