Class: Ciri::P2P::Address
- Inherits:
-
Object
- Object
- Ciri::P2P::Address
- Defined in:
- lib/ciri/p2p/address.rb
Instance Attribute Summary collapse
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#tcp_port ⇒ Object
readonly
Returns the value of attribute tcp_port.
-
#udp_port ⇒ Object
readonly
Returns the value of attribute udp_port.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(ip:, udp_port:, tcp_port: udp_port) ⇒ Address
constructor
A new instance of Address.
- #inspect ⇒ Object
Constructor Details
#initialize(ip:, udp_port:, tcp_port: udp_port) ⇒ Address
Returns a new instance of Address.
30 31 32 33 34 |
# File 'lib/ciri/p2p/address.rb', line 30 def initialize(ip:, udp_port:, tcp_port: udp_port) @ip = ip.is_a?(IPAddr) ? ip : IPAddr.new(ip) @udp_port = udp_port @tcp_port = tcp_port end |
Instance Attribute Details
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
28 29 30 |
# File 'lib/ciri/p2p/address.rb', line 28 def ip @ip end |
#tcp_port ⇒ Object (readonly)
Returns the value of attribute tcp_port.
28 29 30 |
# File 'lib/ciri/p2p/address.rb', line 28 def tcp_port @tcp_port end |
#udp_port ⇒ Object (readonly)
Returns the value of attribute udp_port.
28 29 30 |
# File 'lib/ciri/p2p/address.rb', line 28 def udp_port @udp_port end |
Instance Method Details
#<=>(other) ⇒ Object
40 41 42 |
# File 'lib/ciri/p2p/address.rb', line 40 def <=>(other) ip <=> other.ip end |
#==(other) ⇒ Object
36 37 38 |
# File 'lib/ciri/p2p/address.rb', line 36 def ==(other) self.class == other.class && ip == other.ip && udp_port == other.udp_port end |
#inspect ⇒ Object
44 45 46 |
# File 'lib/ciri/p2p/address.rb', line 44 def inspect "<PeerStore::Address #{ip.inspect} udp_port: #{udp_port} tcp_port: #{tcp_port}>" end |