Class: CMUX::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/cmux/channel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device, port, mux) ⇒ Channel

Returns a new instance of Channel.



6
7
8
9
10
# File 'lib/cmux/channel.rb', line 6

def initialize(device, port, mux)
  @device = device
  @port = port
  @mux = mux
end

Instance Attribute Details

#deviceObject (readonly)

Returns the value of attribute device.



3
4
5
# File 'lib/cmux/channel.rb', line 3

def device
  @device
end

#portObject (readonly)

Returns the value of attribute port.



4
5
6
# File 'lib/cmux/channel.rb', line 4

def port
  @port
end

Instance Method Details

#closeObject



25
26
27
# File 'lib/cmux/channel.rb', line 25

def close
  @mux.close_port @port
end

#open(&block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cmux/channel.rb', line 12

def open(&block)
  io = IO.open_tty @device
  if block_given?
    begin
      yield io
    ensure
      io.close
    end
  else
    io
  end
end