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.1.2"
Class Method Summary collapse
Instance Method Summary collapse
- #exit ⇒ Object
-
#initialize ⇒ ShellBase
constructor
A new instance of ShellBase.
- #method_missing(method_name) ⇒ Object
- #readline ⇒ Object
Constructor Details
#initialize ⇒ ShellBase
Returns a new instance of ShellBase.
10 11 12 13 |
# File 'lib/shell_base.rb', line 10 def initialize @prompt = @@default_prompt while readline; end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object
20 21 22 |
# File 'lib/shell_base.rb', line 20 def method_missing(method_name) puts method_name.to_s + ": Command not found" end |
Class Method Details
.prompt(s) ⇒ Object
6 7 8 |
# File 'lib/shell_base.rb', line 6 def self.prompt(s) @@default_prompt = s end |
Instance Method Details
#readline ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/shell_base.rb', line 24 def readline input = Readline.readline(@prompt, true).split(" ") cmd = input.shift begin send(cmd, *input) rescue Exit return false end true end |