Class: Rpremote::Terminal

Inherits:
Object
  • Object
show all
Defined in:
lib/rpremote/terminal.rb,
sig/rpremote.rbs

Constant Summary collapse

EXIT_BYTE =

Returns:

  • (Integer)
0x1D
BUFFER_SIZE =

Returns:

  • (Integer)
4096

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(serial_io, input: $stdin, output: $stdout, selector: nil) ⇒ Terminal

Returns a new instance of Terminal.



12
13
14
15
16
17
# File 'lib/rpremote/terminal.rb', line 12

def initialize(serial_io, input: $stdin, output: $stdout, selector: nil)
  @serial_io = serial_io
  @input = input
  @output = output
  @selector = selector || ->(readers) { IO.select(readers) }
end

Instance Attribute Details

#inputIO (readonly)

Returns the value of attribute input.

Returns:

  • (IO)


10
11
12
# File 'lib/rpremote/terminal.rb', line 10

def input
  @input
end

#outputIO (readonly)

Returns the value of attribute output.

Returns:

  • (IO)


10
11
12
# File 'lib/rpremote/terminal.rb', line 10

def output
  @output
end

#serial_ioObject (readonly)

Returns the value of attribute serial_io.

Returns:

  • (Object)


10
11
12
# File 'lib/rpremote/terminal.rb', line 10

def serial_io
  @serial_io
end

Instance Method Details

#run(exit_sequence: nil) ⇒ nil

Parameters:

  • exit_sequence: (String, nil) (defaults to: nil)

Returns:

  • (nil)


19
20
21
22
23
# File 'lib/rpremote/terminal.rb', line 19

def run(exit_sequence: nil)
  with_raw_input { relay }
ensure
  leave_interactive_mode(exit_sequence)
end