21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/todos_cli.rb', line 21
def self.append_features(klass)
def klass.
@commands ||= constants.reject{ |command| command =~ /basic/i }.collect { |command| const_get(command).extend(MenuItem) }.sort { |a, b| a::KEY <=> b::KEY }
process_user_input
end
def klass.
puts
@commands.each do |command|
puts command.
end
end
def klass.process_user_input
print 'Command:_ '
user_input = gets.strip.downcase
puts
command = @commands.detect { |command| command::KEY.eql? user_input }
call_command(command) if command
end
end
|