Class: Pport::LinuxPport
- Inherits:
-
Object
- Object
- Pport::LinuxPport
- Defined in:
- lib/linux_pport.rb
Overview
Class representing a parallel port on a linux operating system.
Uses the file /dev/port to interact with the parallel port.
Instance Method Summary collapse
-
#initialize(address) ⇒ LinuxPport
constructor
Opens the file /dev/port for reading and writing.
-
#read ⇒ Object
Seeks the port’s address and reads the value there.
-
#write(val) ⇒ Object
Seeks the port’s address and writes val to that location.
Constructor Details
#initialize(address) ⇒ LinuxPport
Opens the file /dev/port for reading and writing.
22 23 24 25 26 |
# File 'lib/linux_pport.rb', line 22 def initialize(address) @address = address @file = File.open('/dev/port', 'r+') end |
Instance Method Details
#read ⇒ Object
Seeks the port’s address and reads the value there.
29 30 31 32 |
# File 'lib/linux_pport.rb', line 29 def read() @file.seek(@address) @file.getc end |
#write(val) ⇒ Object
Seeks the port’s address and writes val to that location.
35 36 37 38 39 |
# File 'lib/linux_pport.rb', line 35 def write(val) @file.seek(@address) @file.putc(val) @file.flush end |