lib/webconsole/repl.rb in webconsole-0.1.18 vs lib/webconsole/repl.rb in webconsole-0.1.19

- old
+ new

@@ -6,20 +6,22 @@ require_relative "repl/lib/output_controller" require_relative "repl/lib/view" class Wrapper require 'pty' + def initialize(command) PTY.spawn(command) do |output, input, pid| Thread.new do output.each { |line| output_controller.parse_output(line) } end @input = input end + end def parse_input(input) input_controller.parse_input(input) write_input(input) @@ -30,29 +32,18 @@ end private def input_controller - if !@input_controller - @input_controller = InputController.new - @input_controller.view = view - end - return @input_controller + @input_controller ||= InputController.new(view) end def output_controller - if !@output_controller - @output_controller = OutputController.new - @output_controller.view = view - end - return @output_controller + @output_controller ||= OutputController.new(view) end def view - if !@view - @view = View.new - end - return @view + @view ||= View.new end end -end \ No newline at end of file +end