Class: HTTPX::Selector::Monitor

Inherits:
Object
  • Object
show all
Defined in:
lib/httpx/selector.rb

Overview

I/O monitor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io, interests, reactor) ⇒ Monitor

Returns a new instance of Monitor.



16
17
18
19
20
21
# File 'lib/httpx/selector.rb', line 16

def initialize(io, interests, reactor)
  @io = io
  @interests = interests
  @reactor = reactor
  @closed = false
end

Instance Attribute Details

#interestsObject

Returns the value of attribute interests.



14
15
16
# File 'lib/httpx/selector.rb', line 14

def interests
  @interests
end

#ioObject

Returns the value of attribute io.



14
15
16
# File 'lib/httpx/selector.rb', line 14

def io
  @io
end

#readinessObject

Returns the value of attribute readiness.



14
15
16
# File 'lib/httpx/selector.rb', line 14

def readiness
  @readiness
end

Instance Method Details

#close(deregister = true) ⇒ Object

closes @io, deregisters from reactor (unless deregister is false)



32
33
34
35
36
37
# File 'lib/httpx/selector.rb', line 32

def close(deregister = true)
  return if @closed

  @closed = true
  @reactor.deregister(@io) if deregister
end

#closed?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/httpx/selector.rb', line 39

def closed?
  @closed
end

#readable?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/httpx/selector.rb', line 23

def readable?
  READABLE.include?(@interests)
end

#to_sObject

:nocov:



44
45
46
# File 'lib/httpx/selector.rb', line 44

def to_s
  "#<#{self.class}: #{@io}(closed:#{@closed}) #{@interests} #{object_id.to_s(16)}>"
end

#writable?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/httpx/selector.rb', line 27

def writable?
  WRITABLE.include?(@interests)
end