Class: Settlers::Address

Inherits:
Struct
  • Object
show all
Includes:
Comparable
Defined in:
lib/settlers/address.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostObject

Returns the value of attribute host

Returns:

  • (Object)

    the current value of host



4
5
6
# File 'lib/settlers/address.rb', line 4

def host
  @host
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/settlers/address.rb', line 4

def name
  @name
end

#portObject

Returns the value of attribute port

Returns:

  • (Object)

    the current value of 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

#ipObject



15
16
17
# File 'lib/settlers/address.rb', line 15

def ip
  IPAddr.new(host)
end

#to_sObject



19
20
21
# File 'lib/settlers/address.rb', line 19

def to_s
  "#{name} (#{host}:#{port})"
end