Class: Terminus::Host

Inherits:
Object
  • Object
show all
Defined in:
lib/terminus/host.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ Host

Returns a new instance of Host.



6
7
8
9
10
# File 'lib/terminus/host.rb', line 6

def initialize(uri)
  @scheme = uri.scheme if uri.respond_to?(:scheme)
  @host   = uri.host
  @port   = uri.port
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



4
5
6
# File 'lib/terminus/host.rb', line 4

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



4
5
6
# File 'lib/terminus/host.rb', line 4

def port
  @port
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/terminus/host.rb', line 16

def eql?(other)
  host == other.host and
  port == other.port
end

#hashObject



22
23
24
# File 'lib/terminus/host.rb', line 22

def hash
  [host, port].hash
end

#schemeObject



12
13
14
# File 'lib/terminus/host.rb', line 12

def scheme
  @scheme || 'http'
end