Class: Qpid::Proton::Selectable

Inherits:
Object
  • Object
show all
Includes:
Util::SwigHelper, Util::Wrapper
Defined in:
lib/core/selectable.rb

Overview

Selectable enables accessing the underlying file descriptors for Messenger.

Constant Summary collapse

PROTON_METHOD_PREFIX =
"pn_selectable"

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::Wrapper

#impl, #impl=, included, registry

Methods included from Util::SwigHelper

included

Constructor Details

#initialize(impl) ⇒ Selectable

Returns a new instance of Selectable.



71
72
73
74
# File 'lib/core/selectable.rb', line 71

def initialize(impl)
  @impl = impl
  self.class.store_instance(self, :pn_selectable_attachments)
end

Class Method Details

.wrap(impl) ⇒ Object



61
62
63
64
65
# File 'lib/core/selectable.rb', line 61

def self.wrap(impl)
  return nil if impl.nil?

  self.fetch_instance(impl, :pn_selectable_attachments) || Selectable.new(impl)
end

Instance Method Details

#deadlineObject



114
115
116
117
118
# File 'lib/core/selectable.rb', line 114

def deadline
  tstamp = Cproton.pn_selectable_get_deadline(@impl)
  return nil if tstamp.nil?
  mills_to_sec(tstamp)
end

#deadline=(deadline) ⇒ Object



120
121
122
# File 'lib/core/selectable.rb', line 120

def deadline=(deadline)
  Cproton.pn_selectable_set_deadline(sec_to_millis(deadline))
end

#fileno(fd = DEFAULT) ⇒ Object

Returns the underlying file descriptor.

This can be used in conjunction with the IO class.



38
39
40
# File 'lib/core/selectable.rb', line 38

def fileno
  Cproton.pn_selectable_get_fd(@impl)
end

#reading=(reading) ⇒ Object



92
93
94
95
96
97
98
99
100
101
# File 'lib/core/selectable.rb', line 92

def reading=(reading)
  if reading.nil?
    reading = false
  elsif reading == "0"
    reading = false
  else
    reading = true
  end
  Cproton.pn_selectable_set_reading(@impl, reading ? true : false)
end

#to_ioObject



124
125
126
# File 'lib/core/selectable.rb', line 124

def to_io
  @io ||= IO.new(fileno)
end

#writing=(writing) ⇒ Object



103
104
105
106
107
108
109
110
111
112
# File 'lib/core/selectable.rb', line 103

def writing=(writing)
  if writing.nil?
    writing = false
  elsif writing == "0"
    writing = false
  else
    writing = true
  end
  Cproton.pn_selectable_set_writing(@impl, writing ? true : false)
end