Class: Kamerling::Addr
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Value
Class Method Details
.[](host, port, prot) ⇒ Object
9 10 11 |
# File 'lib/kamerling/addr.rb', line 9 def self.[](host, port, prot) new(host: host, port: port, prot: prot) end |
Instance Method Details
#connectable? ⇒ Boolean
13 14 15 16 17 18 |
# File 'lib/kamerling/addr.rb', line 13 def connectable? TCPSocket.open(*self).close true rescue Errno::ECONNREFUSED false end |
#to_a ⇒ Object
20 21 22 |
# File 'lib/kamerling/addr.rb', line 20 def to_a [host, port] end |
#to_h ⇒ Object
24 25 26 |
# File 'lib/kamerling/addr.rb', line 24 def to_h attributes.merge(prot: prot.to_s) end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/kamerling/addr.rb', line 28 def to_s uri.to_s end |
#uri ⇒ Object
32 33 34 |
# File 'lib/kamerling/addr.rb', line 32 def uri URI.parse("#{prot.downcase}://#{host}:#{port}") end |