Class: Path::URL
Overview
A wrapper for URL objects.
Constant Summary
Constants inherited from Path
AUTOGENERATED_CLASS_METHODS, BINARY_EXTENSION, PATH_SEPARATOR
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Attributes inherited from Path
Instance Method Summary collapse
-
#host ⇒ Object
…and this is: ‘host.com’.
-
#initialize(uri, hints = {}) ⇒ URL
constructor
TODO: only include certain methods from Path (delegate style) (eg: remove commands that write).
- #join(other) ⇒ Object
-
#open(mode = "r", &block) ⇒ Object
…and ‘path` is /path/filename.ext.
-
#port ⇒ Object
…and this is: 80.
-
#query ⇒ Object
…and this is: {param1: value1, param2: value2, …etc… }.
-
#read(*args) ⇒ Object
Note: open is already aliased to io in parent class.
-
#scheme ⇒ Object
(also: #protocol)
…this is: ‘http’.
-
#to_s ⇒ Object
Example:.
- #uri? ⇒ Boolean
Methods inherited from Path
#/, #<=>, #==, #=~, [], #[], #[]=, #append, #atime, #atime=, #attrs, #attrs=, #backup!, #backup_file, #broken_symlink?, cd, #cd, #child_of?, #chmod, #chmod_R, #chown, #chown_R, #cp, #cp_r, #ctime, #deflate, #dir, #dir=, #dir?, #each_chunk, #each_line, #endswith, escape, #executable?, #exists?, expand_path, #exts, #file?, #filename, #filename=, getfattr, glob, #grep, #gunzip!, #gzip!, home, #inflate, #initialize_copy, #inspect, #ln_s, ln_s, ls, #ls, #ls_R, #ls_dirs, #ls_files, ls_r, #ls_r, #lstat, #magic, #md5, #mimetype, #mimetype_from_ext, #mode, #mtime, #mtime=, #mv, #mv!, #name, #nicelines, #numbered_backup!, #numbered_backup_file, #owner?, #parent, #parent_of?, #parse, #path, #path=, popd, pushd, pwd, #read_bson, #read_csv, #read_html, #read_json, #read_marshal, #read_xml, #read_yaml, #readable?, #realpath, #relative, #relative?, #relative_to, #reload!, #rename, #rename!, #reset!, #rm, setfattr, #sha1, #sha2, #siblings, #size, #sort_attrs, #startswith, #symlink?, #symlink_target, tmpdir, tmpfile, #to_Path, #touch, #truncate, #type, #unmarshal, #update, #url?, which, #writable?, #write, #write_bson, #write_json, #write_marshal, #write_yaml
Constructor Details
#initialize(uri, hints = {}) ⇒ URL
TODO: only include certain methods from Path (delegate style)
(eg: remove commands that write)
1380 1381 1382 1383 |
# File 'lib/epitools/path.rb', line 1380 def initialize(uri, hints={}) @uri = URI.parse(uri) self.path = @uri.path end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
1374 1375 1376 |
# File 'lib/epitools/path.rb', line 1374 def uri @uri end |
Instance Method Details
#host ⇒ Object
…and this is: ‘host.com’
1406 |
# File 'lib/epitools/path.rb', line 1406 def host; uri.host; end |
#join(other) ⇒ Object
1424 1425 1426 |
# File 'lib/epitools/path.rb', line 1424 def join(other) Path.new URI.join(path, other).to_s end |
#open(mode = "r", &block) ⇒ Object
…and ‘path` is /path/filename.ext
1431 1432 1433 1434 1435 1436 1437 1438 |
# File 'lib/epitools/path.rb', line 1431 def open(mode="r", &block) require 'open-uri' if block_given? open(to_s, mode, &block) else open(to_s, mode) end end |
#port ⇒ Object
…and this is: 80
1411 |
# File 'lib/epitools/path.rb', line 1411 def port; uri.port; end |
#query ⇒ Object
…and this is: {param1: value1, param2: value2, …etc… }
1416 1417 1418 1419 1420 1421 1422 |
# File 'lib/epitools/path.rb', line 1416 def query if query = uri.query query.to_params else nil end end |
#read(*args) ⇒ Object
Note: open is already aliased to io in parent class.
1441 1442 1443 1444 1445 1446 1447 1448 1449 |
# File 'lib/epitools/path.rb', line 1441 def read(*args) require 'open-uri' case scheme when /https?/i io.read(*args) else raise "No connector for #{scheme} yet. Please fix!" end end |
#scheme ⇒ Object Also known as: protocol
…this is: ‘http’
1400 |
# File 'lib/epitools/path.rb', line 1400 def scheme; uri.scheme; end |
#to_s ⇒ Object
Example:
When this is: host.com:port/path/filename.ext?param1=value1¶m2=value2&…
1394 |
# File 'lib/epitools/path.rb', line 1394 def to_s; uri.to_s; end |
#uri? ⇒ Boolean
1385 1386 1387 |
# File 'lib/epitools/path.rb', line 1385 def uri? true end |