Class: Settlers::Address
- Inherits:
-
Struct
- Object
- Struct
- Settlers::Address
- Includes:
- Comparable
- Defined in:
- lib/settlers/address.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#name ⇒ Object
Returns the value of attribute name.
-
#port ⇒ Object
Returns the value of attribute port.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host
4 5 6 |
# File 'lib/settlers/address.rb', line 4 def host @host end |
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/settlers/address.rb', line 4 def name @name end |
#port ⇒ Object
Returns the value of attribute port
4 5 6 |
# File 'lib/settlers/address.rb', line 4 def port @port end |
Class Method Details
.from(reply, info) ⇒ Object
7 8 9 |
# File 'lib/settlers/address.rb', line 7 def self.from(reply, info) new reply.name, info.address, reply.port end |
Instance Method Details
#<=>(other) ⇒ Object
11 12 13 |
# File 'lib/settlers/address.rb', line 11 def <=>(other) [name, ip, port] <=> [other.name, other.ip, other.port] end |
#ip ⇒ Object
15 16 17 |
# File 'lib/settlers/address.rb', line 15 def ip IPAddr.new(host) end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/settlers/address.rb', line 19 def to_s "#{name} (#{host}:#{port})" end |