Class: Ragweed::Device
Instance Method Summary collapse
-
#initialize(path, options = {}) ⇒ Device
constructor
A new instance of Device.
- #ioctl(code, inbuf, outbuf) ⇒ Object
- #read(sz) ⇒ Object
- #release ⇒ Object
- #write(buf) ⇒ Object
Constructor Details
#initialize(path, options = {}) ⇒ Device
Returns a new instance of Device.
3 4 5 6 7 |
# File 'lib/ragweed/wrap32/device.rb', line 3 def initialize(path, ={}) @path = path @options = @h = Ragweed::Wrap32::create_file(@path, :flags => Ragweed::Wrap32::FileAttributes::OVERLAPPED|Ragweed::Wrap32::FileAttributes::NORMAL) end |
Instance Method Details
#ioctl(code, inbuf, outbuf) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/ragweed/wrap32/device.rb', line 9 def ioctl(code, inbuf, outbuf) overlap(lambda do |o| Ragweed::Wrap32::device_io_control(@h, code, inbuf, outbuf, o) end) do |ret, count| outbuf[0..count] end end |
#read(sz) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/ragweed/wrap32/device.rb', line 17 def read(sz) overlap(lambda do |o| Ragweed::Wrap32::read_file(@h, sz, o) end) do |ret, count| ret[0..count] end end |
#release ⇒ Object
33 34 35 36 |
# File 'lib/ragweed/wrap32/device.rb', line 33 def release Ragweed::Wrap32::close_handle(@h) @h = nil end |
#write(buf) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/ragweed/wrap32/device.rb', line 25 def write(buf) overlap(lambda do |o| Ragweed::Wrap32::write_file(@h, buf, o) end) do |ret, count| count end end |