Class: WebConsole::REPL::OutputController

Inherits:
Controller
  • Object
show all
Defined in:
lib/webconsole/repl/lib/output_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ OutputController

Returns a new instance of OutputController.



5
6
7
# File 'lib/webconsole/repl/lib/output_controller.rb', line 5

def initialize(view)
  @view = view
end

Instance Attribute Details

#viewObject

Returns the value of attribute view.



4
5
6
# File 'lib/webconsole/repl/lib/output_controller.rb', line 4

def view
  @view
end

Instance Method Details

#parse_output(output) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/webconsole/repl/lib/output_controller.rb', line 9

def parse_output(output)
  output = output.dup
  output.gsub!(/\x1b[^m]*m/, "") # Remove escape sequences
  output.chomp!
  if !output.strip.empty? # Ignore empty lines
    @view.add_output(output)
  end
end