Class: Seriamp::Backend::SerialPortBackend::Device
- Inherits:
-
Object
- Object
- Seriamp::Backend::SerialPortBackend::Device
- Extended by:
- Forwardable
- Defined in:
- lib/seriamp/backend/serial_port.rb
Instance Attribute Summary collapse
-
#device ⇒ Object
readonly
Returns the value of attribute device.
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Instance Method Summary collapse
-
#initialize(device, logger: nil) ⇒ Device
constructor
A new instance of Device.
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
#device ⇒ Object (readonly)
Returns the value of attribute device.
26 27 28 |
# File 'lib/seriamp/backend/serial_port.rb', line 26 def device @device end |
#io ⇒ Object (readonly)
Returns the value of attribute io.
28 29 30 |
# File 'lib/seriamp/backend/serial_port.rb', line 28 def io @io end |