Class: Ragweed::Device

Inherits:
Object show all
Defined in:
lib/ragweed/wrap32/device.rb

Instance Method Summary collapse

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, options={})
  @path = path
  @options = 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

#releaseObject



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