Class: SurroGate::Pair

Inherits:
Object
  • Object
show all
Defined in:
lib/surro-gate/pair.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, right) ⇒ Pair

Returns a new instance of Pair.



7
8
9
10
11
# File 'lib/surro-gate/pair.rb', line 7

def initialize(left, right)
  @left = left
  @right = right
  unmark
end

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



5
6
7
# File 'lib/surro-gate/pair.rb', line 5

def left
  @left
end

#rightObject (readonly)

Returns the value of attribute right.



5
6
7
# File 'lib/surro-gate/pair.rb', line 5

def right
  @right
end

Instance Method Details

#mark_rdObject



25
26
27
# File 'lib/surro-gate/pair.rb', line 25

def mark_rd
  @rd_rdy = true
end

#mark_wrObject



29
30
31
# File 'lib/surro-gate/pair.rb', line 29

def mark_wr
  @wr_rdy = true
end

#marked_rd?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/surro-gate/pair.rb', line 17

def marked_rd?
  @rd_rdy
end

#marked_wr?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/surro-gate/pair.rb', line 21

def marked_wr?
  @wr_rdy
end

#ready?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/surro-gate/pair.rb', line 13

def ready?
  @rd_rdy && @wr_rdy || @left.closed? || @right.closed?
end

#unmarkObject



33
34
35
# File 'lib/surro-gate/pair.rb', line 33

def unmark
  @rd_rdy = @wr_rdy = false
end