Class: ShellBase
- Inherits:
-
Object
- Object
- ShellBase
- Defined in:
- lib/shell_base.rb,
lib/shell_base/version.rb
Defined Under Namespace
Classes: Exit
Constant Summary collapse
- VERSION =
"0.2.1"
Instance Method Summary collapse
- #exit ⇒ Object
-
#initialize ⇒ ShellBase
constructor
A new instance of ShellBase.
- #method_missing(method_name) ⇒ Object
- #prompt ⇒ Object
- #readline ⇒ Object
Constructor Details
#initialize ⇒ ShellBase
Returns a new instance of ShellBase.
7 8 9 |
# File 'lib/shell_base.rb', line 7 def initialize while readline; end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object
19 20 21 |
# File 'lib/shell_base.rb', line 19 def method_missing(method_name) puts method_name.to_s + ": Command not found" end |
Instance Method Details
#prompt ⇒ Object
11 12 13 |
# File 'lib/shell_base.rb', line 11 def prompt "$ " end |
#readline ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/shell_base.rb', line 23 def readline input = Readline.readline(prompt, true).split(" ") cmd = input.shift if cmd begin send(cmd, *input) rescue Exit return false end end true end |