class NyanCat::NyanServer
Public Class Methods
new(port, address, options = {})
click to toggle source
Calls superclass method
# File lib/nyancat.rb, line 141 def initialize(port, address, options = {}) @options = options @options[:mute] = true @timeout = @options[:timeout] super(port, address) end
Public Instance Methods
serve(io)
click to toggle source
# File lib/nyancat.rb, line 148 def serve(io) n = NyanCat.new(io, @options) begin # run the animation thread t = Thread.new(n) { |nyan| nyan.run() } # block until any input is received or timeout is reached, then die Timeout::timeout(@timeout) { io.readline() } rescue Exception => e log("Client error: #{e}") ensure n.stop t.join end end