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.


8
9
10
11
# File 'lib/dizby/tunnel/factory.rb', line 8

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

Instance Method Details

#bidirectional?Boolean

Returns:

  • (Boolean)

17
18
19
# File 'lib/dizby/tunnel/factory.rb', line 17

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

#create(type)


13
14
15
# File 'lib/dizby/tunnel/factory.rb', line 13

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

#strategy


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

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