Class: Seriamp::Backend::SerialPortBackend::Device

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/seriamp/backend/serial_port.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(device, logger: nil) ⇒ Device

Returns a new instance of Device.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/seriamp/backend/serial_port.rb', line 13

def initialize(device, logger: nil)
  @logger = logger
  @io = SerialPort.open(device)

  if block_given?
    begin
      yield self
    ensure
      close rescue nil
    end
  end
end

Instance Attribute Details

#deviceObject (readonly)

Returns the value of attribute device.



26
27
28
# File 'lib/seriamp/backend/serial_port.rb', line 26

def device
  @device
end

#ioObject (readonly)

Returns the value of attribute io.



28
29
30
# File 'lib/seriamp/backend/serial_port.rb', line 28

def io
  @io
end