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.



10
11
12
13
14
15
# File 'lib/httpx/selector.rb', line 10

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

Instance Attribute Details

#interestsObject

Returns the value of attribute interests.



8
9
10
# File 'lib/httpx/selector.rb', line 8

def interests
  @interests
end

#readinessObject

Returns the value of attribute readiness.



8
9
10
# File 'lib/httpx/selector.rb', line 8

def readiness
  @readiness
end

#valueObject

Returns the value of attribute value.



8
9
10
# File 'lib/httpx/selector.rb', line 8

def value
  @value
end

Instance Method Details

#close(deregister = true) ⇒ Object

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



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

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

#closed?Boolean

Returns:

  • (Boolean)


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

def closed?
  @closed
end

#readable?Boolean

Returns:

  • (Boolean)


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

def readable?
  @interests == :rw || @interests == :r
end

#to_sObject

:nocov:



37
38
39
# File 'lib/httpx/selector.rb', line 37

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

#writable?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/httpx/selector.rb', line 21

def writable?
  @interests == :rw || @interests == :w
end