Class: FTPMVC::Server
- Inherits:
-
Object
- Object
- FTPMVC::Server
- Defined in:
- lib/ftpmvc/server.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(host = '0.0.0.0', port) ⇒ Server
constructor
A new instance of Server.
- #start(application) {|_self| ... } ⇒ Object
- #start_in_new_thread(application) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(host = '0.0.0.0', port) ⇒ Server
Returns a new instance of Server.
9 10 11 |
# File 'lib/ftpmvc/server.rb', line 9 def initialize(host='0.0.0.0', port) @host, @port = host, port end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
7 8 9 |
# File 'lib/ftpmvc/server.rb', line 7 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
7 8 9 |
# File 'lib/ftpmvc/server.rb', line 7 def port @port end |
Instance Method Details
#start(application) {|_self| ... } ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/ftpmvc/server.rb', line 22 def start(application) start_in_new_thread(application) yield self if block_given? # Manter o instance_variable_get até o pull request #29 ser aprovado # o uma nova versão ficar disponível. @server.instance_variable_get(:@server_thread).join # @server.join end |
#start_in_new_thread(application) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/ftpmvc/server.rb', line 13 def start_in_new_thread(application) driver = Ftpd::Driver.new(application) @server = ::Ftpd::FtpServer.new(driver) @server.interface, @server.port = @address, @port @server.start @port = @server.bound_port self end |
#stop ⇒ Object
31 32 33 |
# File 'lib/ftpmvc/server.rb', line 31 def stop @server.stop end |