Class: SafariBookmarksParser::Runner
- Inherits:
-
Object
- Object
- SafariBookmarksParser::Runner
- Defined in:
- lib/safari_bookmarks_parser/runner.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ Runner
Returns a new instance of Runner.
17 18 19 20 21 22 23 |
# File 'lib/safari_bookmarks_parser/runner.rb', line 17 def initialize(argv) @argv = argv.dup @parser = nil (@argv) end |
Class Method Details
.known_commands ⇒ Object
8 9 10 |
# File 'lib/safari_bookmarks_parser/runner.rb', line 8 def known_commands @known_commands ||= {} end |
.register_command(command_name, command_class) ⇒ Object
12 13 14 |
# File 'lib/safari_bookmarks_parser/runner.rb', line 12 def register_command(command_name, command_class) known_commands[command_name.to_sym] = command_class end |
Instance Method Details
#run ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/safari_bookmarks_parser/runner.rb', line 25 def run command_name = @argv.shift if command_name command_class = self.class.known_commands[command_name.to_sym] raise Error, "unknown command: #{command_name}" unless command_class command_class.new(@argv).run else show_help(@parser) end end |