class Aqueductron::Piece

Attributes

destination[R]

Public Class Methods

new(destination, what_to_do, description = "~") click to toggle source
# File lib/aqueductron/piece.rb, line 14
def initialize(destination, what_to_do, description = "~")
  @destination = destination
  @what_to_do = what_to_do
  @description = description
end

Public Instance Methods

draw() click to toggle source
# File lib/aqueductron/piece.rb, line 9
def draw
  desc = " " + @description + " "
  Drawing.horizontal_concat(Drawing.draw_mid_piece(desc),@destination.draw)
end
eof() click to toggle source
# File lib/aqueductron/piece.rb, line 24
def eof
  send_eof
end
pass_on(msg, what_to_do_next, description = "~") click to toggle source
# File lib/aqueductron/piece.rb, line 28
def pass_on(msg, what_to_do_next, description = "~")
  next_destination = @destination.receive(msg)
  if (next_destination.result?) then
    next_destination # not a destination at all; result
  else
    Piece.new(next_destination, what_to_do_next, description)
  end
end
receive(msg) click to toggle source
# File lib/aqueductron/piece.rb, line 20
def receive(msg)
  @what_to_do.call(self, msg)
end
send_eof() click to toggle source
# File lib/aqueductron/piece.rb, line 36
def send_eof
  @destination.eof
end