Class: FTPUtils::FTPURI
- Inherits:
-
Object
- Object
- FTPUtils::FTPURI
- Defined in:
- lib/ftputils/ftpuri.rb
Instance Attribute Summary collapse
-
#dirname ⇒ Object
Returns the value of attribute dirname.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dirname, filename, path) ⇒ FTPURI
constructor
A new instance of FTPURI.
Constructor Details
#initialize(dirname, filename, path) ⇒ FTPURI
19 20 21 22 23 |
# File 'lib/ftputils/ftpuri.rb', line 19 def initialize(dirname, filename, path) self.dirname = dirname self.filename = filename self.path = path end |
Instance Attribute Details
#dirname ⇒ Object
Returns the value of attribute dirname.
3 4 5 |
# File 'lib/ftputils/ftpuri.rb', line 3 def dirname @dirname end |
#filename ⇒ Object
Returns the value of attribute filename.
3 4 5 |
# File 'lib/ftputils/ftpuri.rb', line 3 def filename @filename end |
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/ftputils/ftpuri.rb', line 3 def path @path end |
Class Method Details
.parse(uri) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ftputils/ftpuri.rb', line 5 def self.parse(uri) if uri.match(/^ftp:\/\/.*?:.*?@.*?(\/.*)*$/) path = $1 || "/" parts = path.split(/\//) filename = parts[-1] dirname = parts[0..-2].join("\/") dirname = "/" if dirname.empty? ftp_uri = FTPURI.new(dirname, filename, path) else return nil end end |