Class: Rib::Shell
- Inherits:
-
Object
show all
- Includes:
- API
- Defined in:
- lib/rib/shell.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from API
#after_loop, #before_loop, #eval_binding, #eval_input, #format_backtrace, format_error, #format_result, get_error, #get_input, #handle_interrupt, #in_loop, #inspect_result, #line, #loop_eval, #loop_once, #name, #print_eval_error, #print_result, #prompt, #puts, #result_prompt, #started_at, #warn
Constructor Details
#initialize(config = {}) ⇒ Shell
37
38
39
40
41
42
43
44
|
# File 'lib/rib/shell.rb', line 37
def initialize(config={})
config[:binding] ||= new_private_binding
self.config = {:result_prompt => '=> ',
:prompt => '>> ',
:exit => [nil],
:line => 1 }.merge(config)
stop
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
12
13
14
|
# File 'lib/rib/shell.rb', line 12
def config
@config
end
|
Class Method Details
.use(mod) ⇒ Object
8
9
10
|
# File 'lib/rib/shell.rb', line 8
def self.use mod
include mod
end
|
Instance Method Details
#loop ⇒ Object
Loops shell until user exits
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/rib/shell.rb', line 47
def loop
before_loop
set_trap
start
in_loop
stop
self
rescue Exception => e
Rib.warn("Error while running loop:\n #{format_error(e)}")
raise
ensure
release_trap
after_loop
end
|
#running? ⇒ Boolean
70
71
72
|
# File 'lib/rib/shell.rb', line 70
def running?
!!@running
end
|
#start ⇒ Object
62
63
64
|
# File 'lib/rib/shell.rb', line 62
def start
@running = true
end
|
#stop ⇒ Object
66
67
68
|
# File 'lib/rib/shell.rb', line 66
def stop
@running = false
end
|
#warnings ⇒ Object
74
75
76
|
# File 'lib/rib/shell.rb', line 74
def warnings
@warnings ||= []
end
|