Class: Intar
- Defined in:
- lib/intar/version.rb,
lib/intar.rb,
lib/intar/prompt.rb,
lib/intar/redirect.rb
Overview
intar/version.rb – Version number
Defined Under Namespace
Classes: Break, Bye, Clear, Failed, Prompt, Quit, Redirect, RedirectFile, RedirectNone, RedirectPipe
Constant Summary collapse
- DEFAULTS =
{ prompt: "%(32)c%16i%c:%1c%d:%3n%c%> ", color: true, show: 1, shownil: false, pager: nil, catch_exit: false, histhid: true, histfile: nil, histmax: 500, }
- VERSION =
"2.13".freeze
Class Attribute Summary collapse
-
.metacmds ⇒ Object
readonly
Returns the value of attribute metacmds.
Instance Attribute Summary collapse
-
#depth ⇒ Object
readonly
Returns the value of attribute depth.
-
#n ⇒ Object
readonly
Returns the value of attribute n.
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#prompt ⇒ Object
readonly
Returns the value of attribute prompt.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.metacmds ⇒ Object (readonly)
Returns the value of attribute metacmds.
374 375 376 |
# File 'lib/intar.rb', line 374 def end |
Instance Attribute Details
#depth ⇒ Object (readonly)
Returns the value of attribute depth.
107 108 109 |
# File 'lib/intar.rb', line 107 def depth @depth end |
#n ⇒ Object (readonly)
Returns the value of attribute n.
107 108 109 |
# File 'lib/intar.rb', line 107 def n @n end |
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
107 108 109 |
# File 'lib/intar.rb', line 107 def obj @obj end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
107 108 109 |
# File 'lib/intar.rb', line 107 def params @params end |
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
107 108 109 |
# File 'lib/intar.rb', line 107 def prompt @prompt end |
Class Method Details
.open(obj = main, **params) {|i| ... } ⇒ Object
51 52 53 54 |
# File 'lib/intar.rb', line 51 def open obj = main, **params i = new obj, **params yield i end |
.run(obj = main, **params) ⇒ Object
56 57 58 |
# File 'lib/intar.rb', line 56 def run obj = main, **params open obj, **params do |i| i.run end end |
Instance Method Details
#execute(code) ⇒ Object
159 160 161 |
# File 'lib/intar.rb', line 159 def execute code @binding.eval code, @file||"#{self.class}/execute" end |
#run ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/intar.rb', line 115 def run handle_history do set_current do execute OLD_INIT loop do l = readline l or break @redir = find_redirect l begin if l.slice! /^\\(\w+|.)\s*(.*?)\s*$\n?/ then r = send ( $1).method, (eval_param $2) l.empty? or @previous = l else begin r = eval_line l rescue SyntaxError raise if l.end_with? $/ @previous = l end end next if @previous display r rescue Clear @previous = nil next rescue Bye raise if @depth.nonzero? break rescue Quit break rescue Exception break if SystemExit === $! and not @params[ :catch_exit] r = $! show_exception end (execute OLD_SET).call r, @n @n += 1 end ensure execute OLD_INIT end end end |
#set_var(name, val) ⇒ Object
163 164 165 |
# File 'lib/intar.rb', line 163 def set_var name, val @binding.local_variable_set name, val end |