Sha256: 9382d18430b166c6c76215944fe02c3945fd278bd0d2478a1f9a09471df1232e

Contents?: true

Size: 714 Bytes

Versions: 2

Compression:

Stored size: 714 Bytes

Contents

module NFS
  class Server
    attr_reader :dir, :host, :port, :protocol

    def initialize(dir:, host:, port:, protocol:)
      @dir = dir
      @host = host
      @port = port
      @protocol = protocol

      @handler = Handler.new(FileProxy.open(dir))
      @server = server_class.new(@handler.programs, port, host)
    end

    def join
      @server.join
    end

    def start
      @server.start
    end

    def shutdown
      @server.shutdown
    end

    private

    def server_class
      if protocol == :tcp
        SUNRPC::TCPServer
      elsif protocol == :udp
        SUNRPC::UDPServer
      else
        raise "Unsupported protocol #{protocol}, expected :tcp or :udp"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nfs-rb-1.0.1 lib/nfs/server.rb
nfs-rb-1.0.0 lib/nfs/server.rb