Class: ZMQ::PollItem

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ffi-rzmq/poll_item.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(zmq_poll_item = nil) ⇒ PollItem

Returns a new instance of PollItem.


11
12
13
# File 'lib/ffi-rzmq/poll_item.rb', line 11

def initialize(zmq_poll_item = nil)
  @poll_item = zmq_poll_item || LibZMQ::PollItem.new
end

Instance Attribute Details

#poll_itemObject

Returns the value of attribute poll_item


9
10
11
# File 'lib/ffi-rzmq/poll_item.rb', line 9

def poll_item
  @poll_item
end

#pollableObject

Returns the value of attribute pollable


9
10
11
# File 'lib/ffi-rzmq/poll_item.rb', line 9

def pollable
  @pollable
end

Class Method Details

.from_pointer(pointer) ⇒ Object


15
16
17
# File 'lib/ffi-rzmq/poll_item.rb', line 15

def self.from_pointer(pointer)
  self.new(LibZMQ::PollItem.new(pointer))
end

.from_pollable(pollable) ⇒ Object


19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ffi-rzmq/poll_item.rb', line 19

def self.from_pollable(pollable)
  item = self.new
  item.pollable = pollable
  case
  when pollable.respond_to?(:socket)
    item.socket = pollable.socket
  when pollable.respond_to?(:posix_fileno)
    item.fd = pollable.posix_fileno
  when pollable.respond_to?(:io)
    item.fd = pollable.io.posix_fileno
  end
  item
end

Instance Method Details

#closed?Boolean

Returns:

  • (Boolean)

33
34
35
36
37
38
39
40
41
42
# File 'lib/ffi-rzmq/poll_item.rb', line 33

def closed?
  case
  when pollable.respond_to?(:closed?)
    pollable.closed?
  when pollable.respond_to?(:socket)
    pollable.socket.nil?
  when pollable.respond_to?(:io)
    pollable.io.closed?
  end
end

#eventsObject


54
# File 'lib/ffi-rzmq/poll_item.rb', line 54

def events; @poll_item[:events]; end

#events=(arg) ⇒ Object


52
# File 'lib/ffi-rzmq/poll_item.rb', line 52

def events=(arg); @poll_item[:events] = arg; end

#fdObject


50
# File 'lib/ffi-rzmq/poll_item.rb', line 50

def fd; @poll_item[:fd]; end

#fd=(arg) ⇒ Object


48
# File 'lib/ffi-rzmq/poll_item.rb', line 48

def fd=(arg); @poll_item[:fd] = arg; end

#socketObject


46
# File 'lib/ffi-rzmq/poll_item.rb', line 46

def socket; @poll_item[:socket]; end

#socket=(arg) ⇒ Object


44
# File 'lib/ffi-rzmq/poll_item.rb', line 44

def socket=(arg); @poll_item[:socket] = arg; end