Sha256: f9e8f3d4e25f8185976ed6c810b0107387c5a463fc5c59694cf1f21a5bf7dafa

Contents?: true

Size: 1020 Bytes

Versions: 6

Compression:

Stored size: 1020 Bytes

Contents

# frozen_string_literal: true

module Vedeu

  # Provides a mechanism to control a running client application via
  # DRb.
  #
  module Distributed

    # Value class which provides the host and port for the DRb server
    # and client.
    #
    class Uri

      # @!attribute [r] host
      # @return [String]
      attr_reader :host

      # @!attribute [r] port
      # @return [Fixnum|String]
      attr_reader :port

      # Returns a new instance of Vedeu::Distributed::Uri.
      #
      # @param host [String] Hostname or IP address.
      # @param port [Fixnum|String]
      # @return [Vedeu::Distributed::Uri]
      def initialize(host = 'localhost', port = 21_420)
        @host = host || 'localhost'
        @port = port || 21_420
      end

      # @example
      #   'druby://localhost:21420'
      #
      # @return [String] The host and port as a single value.
      def to_s
        "druby://#{host}:#{port}"
      end
      alias_method :to_str, :to_s

    end # Uri

  end # Distributed

end # Vedeu

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vedeu-0.8.6 lib/vedeu/distributed/uri.rb
vedeu-0.8.5 lib/vedeu/distributed/uri.rb
vedeu-0.8.4 lib/vedeu/distributed/uri.rb
vedeu-0.8.3 lib/vedeu/distributed/uri.rb
vedeu-0.8.2 lib/vedeu/distributed/uri.rb
vedeu-0.8.1 lib/vedeu/distributed/uri.rb