class HTTPClient::Site

Represents a Site: protocol scheme, host String and port Number.

Constants

EMPTY

Attributes

host[RW]

Host String.

hostname[RW]

Host String.

port[RW]

Port number.

scheme[RW]

Protocol scheme.

Public Class Methods

new(uri = nil) click to toggle source

Creates a new Site based on the given URI.

# File lib/httpclient/session.rb, line 45
def initialize(uri = nil)
  if uri
    @scheme = uri.scheme || 'tcp'
    @host = uri.hostname || '0.0.0.0'
    @port = uri.port.to_i
  else
    @scheme = 'tcp'
    @host = '0.0.0.0'
    @port = 0
  end
end

Public Instance Methods

==(rhs) click to toggle source

Returns true is scheme, host and port are ‘==’

# File lib/httpclient/session.rb, line 63
def ==(rhs)
  (@scheme == rhs.scheme) and (@host == rhs.host) and (@port == rhs.port)
end
addr() click to toggle source

Returns address String.

# File lib/httpclient/session.rb, line 58
def addr
  "#{@scheme}://#{@host}:#{@port.to_s}"
end
eql?(rhs) click to toggle source

Same as ==.

# File lib/httpclient/session.rb, line 68
def eql?(rhs)
  self == rhs
end
match(uri) click to toggle source

Returns true if scheme, host and port of the given URI matches with this.

# File lib/httpclient/session.rb, line 81
def match(uri)
  (@scheme == uri.scheme) and (@host == uri.host) and (@port == uri.port.to_i)
end