Skip to content

Commit 9899e08

Browse files
committed
Added a without/with NiFTP usage example.
* Also cleaned up the concrete example.
1 parent 1acfd45 commit 9899e08

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,30 @@ connections. Options include retrying your commands on flakey FTP servers, and
44
forced timeouts. FTP Secure (FTPS) is also supported.
55

66
## Usage
7+
# Without NiFTP:
8+
begin
9+
client = Net::FTP.new("localhost")
10+
client.list
11+
ensure
12+
client.try(:close)
13+
end
14+
15+
# With NiFTP:
16+
ftp("localhost") { |client| client.list }
17+
18+
# A more concrete example:
719

820
# Mixin the +NiFTP+ module, which provides the +ftp+ method.
921
class SomeObject
1022
include NiFTP
1123

1224
def ftp_stuff
13-
# put a file using no username, password or other options
14-
ftp("localhost") { |client| client.put("some_file.txt") }
15-
16-
# get a file on an FTP Secure (FTPS) server
25+
# get a file from an FTP Secure (FTPS) server
1726
ftp("ftp.secure.com", { username: "some_user", password: "FTP_FTL",
18-
ftps: true }) do |client|
19-
client.resume = true
20-
file = client.get("some_file.txt")
27+
ftps: true }) do |client|
28+
files = client.list('n*')
29+
# ...
30+
file = client.getbinaryfile('nif.rb-0.91.gz', 'nif.gz', 1024)
2131
# ...
2232
end
2333
end

0 commit comments

Comments
 (0)