Class: Locomotive::Wagon::TcpPort
- Inherits:
-
Object
- Object
- Locomotive::Wagon::TcpPort
- Defined in:
- lib/locomotive/wagon/tools/tcp_port.rb
Constant Summary collapse
- MAX_ATTEMPTS =
1000
Instance Method Summary collapse
- #first ⇒ Object
-
#initialize(host, from) ⇒ TcpPort
constructor
A new instance of TcpPort.
Constructor Details
#initialize(host, from) ⇒ TcpPort
Returns a new instance of TcpPort.
10 11 12 13 |
# File 'lib/locomotive/wagon/tools/tcp_port.rb', line 10 def initialize(host, from) @host = host @from = from end |
Instance Method Details
#first ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/locomotive/wagon/tools/tcp_port.rb', line 15 def first current = @from.to_i max = current + MAX_ATTEMPTS while open_port(@host, current) current += 1 raise "No available ports from #{@from}" if current >= max end current.to_s end |