Class: Terminus::Host
- Inherits:
-
Object
- Object
- Terminus::Host
- Defined in:
- lib/terminus/host.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(uri) ⇒ Host
constructor
A new instance of Host.
- #scheme ⇒ Object
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
#host ⇒ Object (readonly)
Returns the value of attribute host.
4 5 6 |
# File 'lib/terminus/host.rb', line 4 def host @host end |
#port ⇒ Object (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: ==
16 17 18 19 |
# File 'lib/terminus/host.rb', line 16 def eql?(other) host == other.host and port == other.port end |
#hash ⇒ Object
22 23 24 |
# File 'lib/terminus/host.rb', line 22 def hash [host, port].hash end |
#scheme ⇒ Object
12 13 14 |
# File 'lib/terminus/host.rb', line 12 def scheme @scheme || 'http' end |