Class: Rib::Shell
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ Shell
constructor
A new instance of Shell.
-
#loop ⇒ Object
Loops shell until user exits.
- #running? ⇒ Boolean
Methods included from API
#after_loop, #before_loop, #bound_object, #eval_binding, #eval_input, #format_error, #format_result, #get_input, #handle_interrupt, #in_loop, #line, #loop_eval, #loop_once, #name, #print_eval_error, #print_result, #prompt, #result_prompt
Constructor Details
#initialize(config = {}) ⇒ Shell
Returns a new instance of Shell.
14 15 16 17 18 19 20 21 22 |
# File 'lib/rib/shell.rb', line 14 def initialize(config={}) self.config = { :result_prompt => '=> ' , :prompt => '>> ' , :binding => TOPLEVEL_BINDING, :exit => [nil] , :line => 1 }.merge(config) @running = false end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
13 14 15 |
# File 'lib/rib/shell.rb', line 13 def config @config end |
Class Method Details
.use(mod) ⇒ Object
9 10 11 |
# File 'lib/rib/shell.rb', line 9 def self.use mod include mod end |
Instance Method Details
#loop ⇒ Object
Loops shell until user exits
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rib/shell.rb', line 25 def loop before_loop @running = true in_loop self rescue Exception => e Rib.warn("Error while running loop:\n #{format_error(e)}") raise ensure @running = false after_loop end |
#running? ⇒ Boolean
38 39 40 |
# File 'lib/rib/shell.rb', line 38 def running? !!@running end |