Class: Rush::EmbeddableShell
- Inherits:
-
Object
- Object
- Rush::EmbeddableShell
- Defined in:
- lib/rush/embeddable_shell.rb
Overview
This is a class that can be embedded in other applications rake tasks, utility scripts, etc
Delegates unknown method calls to a Rush::Shell instance
Instance Attribute Summary collapse
-
#shell ⇒ Object
Returns the value of attribute shell.
Instance Method Summary collapse
-
#execute_in_shell(&block) ⇒ Object
take a whole block and execute it as if it were inside a shell.
-
#initialize(suppress_output = true) ⇒ EmbeddableShell
constructor
A new instance of EmbeddableShell.
-
#method_missing(sym, *args, &block) ⇒ Object
evalutes and unkown method call agains the rush shell.
Constructor Details
#initialize(suppress_output = true) ⇒ EmbeddableShell
Returns a new instance of EmbeddableShell.
10 11 12 13 |
# File 'lib/rush/embeddable_shell.rb', line 10 def initialize(suppress_output = true) self.shell = Rush::Shell.new shell.suppress_output = suppress_output end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
evalutes and unkown method call agains the rush shell
16 17 18 19 |
# File 'lib/rush/embeddable_shell.rb', line 16 def method_missing(sym, *args, &block) shell.execute sym.to_s $last_res end |
Instance Attribute Details
#shell ⇒ Object
Returns the value of attribute shell.
9 10 11 |
# File 'lib/rush/embeddable_shell.rb', line 9 def shell @shell end |
Instance Method Details
#execute_in_shell(&block) ⇒ Object
take a whole block and execute it as if it were inside a shell
22 23 24 |
# File 'lib/rush/embeddable_shell.rb', line 22 def execute_in_shell(&block) self.instance_eval(&block) end |