Class: Wokku::PtySession
- Inherits:
-
Object
- Object
- Wokku::PtySession
- Defined in:
- lib/wokku/pty_session.rb
Instance Attribute Summary collapse
-
#exit_code ⇒ Object
readonly
Returns the value of attribute exit_code.
Instance Method Summary collapse
-
#initialize(cable:, tty:) ⇒ PtySession
constructor
A new instance of PtySession.
-
#run ⇒ Object
Runs until @done is set by an “exit” or “error” message.
- #start!(mode:, target:, argv: []) ⇒ Object
Constructor Details
#initialize(cable:, tty:) ⇒ PtySession
Returns a new instance of PtySession.
10 11 12 13 14 15 |
# File 'lib/wokku/pty_session.rb', line 10 def initialize(cable:, tty:) @cable = cable @tty = tty @exit_code = nil @done = false end |
Instance Attribute Details
#exit_code ⇒ Object (readonly)
Returns the value of attribute exit_code.
8 9 10 |
# File 'lib/wokku/pty_session.rb', line 8 def exit_code @exit_code end |
Instance Method Details
#run ⇒ Object
Runs until @done is set by an “exit” or “error” message. Optional block (used in specs) is called once per pump tick and may return :stop.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/wokku/pty_session.rb', line 24 def run install_signal_handlers if @tty IO.console.raw! if @tty begin loop do break if @done forward_stdin if @tty @cable.pump(0.05) break if block_given? && yield == :stop end ensure IO.console.cooked! if @tty end end |
#start!(mode:, target:, argv: []) ⇒ Object
17 18 19 20 |
# File 'lib/wokku/pty_session.rb', line 17 def start!(mode:, target:, argv: []) rows, cols = current_winsize @cable.(type: "start", mode: mode, target: target, argv: argv, cols: cols, rows: rows) end |