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
Create a new 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_error, #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
Create a new shell.
38 39 40 41 42 43 44 45 |
# File 'lib/rib/shell.rb', line 38 def initialize(config={}) config[:binding] ||= new_private_binding self.config = {:result_prompt => '=> ', :prompt => '>> ', :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
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rib/shell.rb', line 48 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
61 62 63 |
# File 'lib/rib/shell.rb', line 61 def running? !!@running end |