Class: Dizby::TunnelFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/dizby/tunnel/factory.rb

Instance Method Summary collapse

Constructor Details

#initialize(server, port) ⇒ TunnelFactory

Returns a new instance of TunnelFactory.


10
11
12
13
# File 'lib/dizby/tunnel/factory.rb', line 10

def initialize(server, port)
  @server = server
  @port = port
end

Instance Method Details

#bidirectional?Boolean

Returns:

  • (Boolean)

19
20
21
# File 'lib/dizby/tunnel/factory.rb', line 19

def bidirectional?
  @server.respond_to?(:port)
end

#create(type)


15
16
17
# File 'lib/dizby/tunnel/factory.rb', line 15

def create(type)
  SemibuiltObject.new(type, @server, strategy)
end

#strategy


23
24
25
26
27
28
29
# File 'lib/dizby/tunnel/factory.rb', line 23

def strategy
  if bidirectional?
    BidirectionalTunnelStrategy.new(@port, @server.port)
  else
    LocalTunnelStrategy.new(@port)
  end
end