Class: IRB::Context
Overview
:nodoc:
Instance Attribute Summary collapse
-
#backtrace_map ⇒ Object
Returns the value of attribute backtrace_map.
-
#binding_file ⇒ Object
Returns the value of attribute binding_file.
-
#binding_line_no ⇒ Object
Returns the value of attribute binding_line_no.
-
#current_line ⇒ Object
Returns the value of attribute current_line.
-
#current_line_no ⇒ Object
readonly
Returns the value of attribute current_line_no.
- #irt_mode ⇒ Object
-
#last_line_no ⇒ Object
readonly
Returns the value of attribute last_line_no.
-
#parent_context ⇒ Object
Returns the value of attribute parent_context.
- #return_ignored_echo_format ⇒ Object
Instance Method Summary collapse
- #evaluate(line, line_no) ⇒ Object
- #evaluate_and_set_last_value ⇒ Object
- #file_line_pointers ⇒ Object
- #original_prompt_mode ⇒ Object
- #prompt_mode=(mode) ⇒ Object
- #return_format ⇒ Object
Instance Attribute Details
#backtrace_map ⇒ Object
Returns the value of attribute backtrace_map.
6 7 8 |
# File 'lib/irt/extensions/irb/context.rb', line 6 def backtrace_map @backtrace_map end |
#binding_file ⇒ Object
Returns the value of attribute binding_file.
6 7 8 |
# File 'lib/irt/extensions/irb/context.rb', line 6 def binding_file @binding_file end |
#binding_line_no ⇒ Object
Returns the value of attribute binding_line_no.
6 7 8 |
# File 'lib/irt/extensions/irb/context.rb', line 6 def binding_line_no @binding_line_no end |
#current_line ⇒ Object
Returns the value of attribute current_line.
6 7 8 |
# File 'lib/irt/extensions/irb/context.rb', line 6 def current_line @current_line end |
#current_line_no ⇒ Object (readonly)
Returns the value of attribute current_line_no.
7 8 9 |
# File 'lib/irt/extensions/irb/context.rb', line 7 def current_line_no @current_line_no end |
#irt_mode ⇒ Object
27 28 29 |
# File 'lib/irt/extensions/irb/context.rb', line 27 def irt_mode @irt_mode ||= :file end |
#last_line_no ⇒ Object (readonly)
Returns the value of attribute last_line_no.
7 8 9 |
# File 'lib/irt/extensions/irb/context.rb', line 7 def last_line_no @last_line_no end |
#parent_context ⇒ Object
Returns the value of attribute parent_context.
6 7 8 |
# File 'lib/irt/extensions/irb/context.rb', line 6 def parent_context @parent_context end |
Instance Method Details
#evaluate(line, line_no) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/irt/extensions/irb/context.rb', line 32 def evaluate(line, line_no) @current_line = line @current_line_no = line_no + line.chomp.count("\n") if @exception_raised IRT::Session.enter(:interactive) if irt_mode == :file @exception_raised = false end log_file_line(line_no) if irt_mode == :file begin # skip setting last_value for non_setting_commands if line =~ /^\s*(#{quoted_option_string(IRT.log.non_setting_commands)})\b(.*)$/ command, args = $1, $2 if command =~ /^(sh|ri|pri)$/ && irt_mode != :file args = args.strip if args line = if args.match(/^('|").+\1$/) command == 'sh' ? "#{command} #{args}" : "#{command} #{args}, true" else args = "%(#{args})" unless args.empty? "#{command} #{args}" end end IRT::Commands::Ri.reset_choices_map unless command =~ /^(ri|pri)$/ self.echo = false res = @workspace.evaluate(self, line, irb_path, line_no) if command =~ /^(#{IRT.log.ignored_echo_commands * '|'})$/ output_ignored_echo_value(res) end else self.echo = irt_mode == :file ? false : true evaluate_and_set_last_value(line, line_no) end rescue Exception => e @exception_raised = true process_exception(e) print Dye.sgr(IRT.dye_styles[:error_color]) if Dye.color? raise else log_session_line(line, line_no) unless irt_mode == :file end end |
#evaluate_and_set_last_value ⇒ Object
31 |
# File 'lib/irt/extensions/irb/context.rb', line 31 alias_method :evaluate_and_set_last_value, :evaluate |
#file_line_pointers ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/irt/extensions/irb/context.rb', line 10 def file_line_pointers file = line = nil c = self until file case c.irt_mode when :binding file = c.binding_file line = c.binding_line_no when :file file = c.irb_path line = c.last_line_no end c = c.parent_context end [file, line] end |
#original_prompt_mode ⇒ Object
94 |
# File 'lib/irt/extensions/irb/context.rb', line 94 alias_method :original_prompt_mode, :prompt_mode= |