Class: KDE::Url
Class Method Summary (collapse)
- + (Object) _load(str)
-
+ (Boolean) file_url?(str, abs_only = false)
Tells whether a string looks like an url pointing to a file.
- + (Object) yaml_new(cls, tag, val)
Instance Method Summary (collapse)
- - (Object) _dump(_)
-
- (Boolean) eql?(other)
true if the two URLs are equal according to
==
and false otherwise. -
- (Integer) hash
Override of Object#hash.
- - (Boolean) local_file?
- - (Boolean) remote_file?
- - (Object) to_yaml(opts = {})
Class Method Details
+ (Object) _load(str)
65 66 67 |
# File 'lib/ruber/kde_sugar.rb', line 65 def self._load str self.new str end |
+ (Boolean) file_url?(str, abs_only = false)
Tells whether a string looks like an url pointing to a file
An url is considered to look like an url pointing to a file if it contains a scheme part and an authority part, that is, if it starts with a scheme followed by two slashes.
If abs_only is true, this method returns true only if the file path is absolute, that is if the scheme is followed by three slashes. If abs_only is false, it’ll return true for both absolute and relative paths.
50 51 52 53 |
# File 'lib/ruber/kde_sugar.rb', line 50 def self.file_url? str, abs_only = false slash_number = abs_only ? 3 : 2 str.match(%r|[\w+.-]+:/{#{slash_number},3}|).to_b end |
+ (Object) yaml_new(cls, tag, val)
30 31 32 |
# File 'lib/ruber/kde_sugar.rb', line 30 def self.yaml_new cls, tag, val KDE::Url.new val end |
Instance Method Details
- (Object) _dump(_)
61 62 63 |
# File 'lib/ruber/kde_sugar.rb', line 61 def _dump _ to_encoded.to_s end |
- (Boolean) eql?(other)
true if the two URLs are equal according to ==
and false
otherwise
81 82 83 |
# File 'lib/ruber/kde_sugar.rb', line 81 def eql? other self == other end |
- (Integer) hash
Override of Object#hash
89 90 91 |
# File 'lib/ruber/kde_sugar.rb', line 89 def hash path.hash end |
- (Boolean) local_file?
69 70 71 |
# File 'lib/ruber/kde_sugar.rb', line 69 def local_file? scheme == "file" end |
- (Boolean) remote_file?
73 74 75 |
# File 'lib/ruber/kde_sugar.rb', line 73 def remote_file? !(local_file? or relative?) end |
- (Object) to_yaml(opts = {})
55 56 57 58 59 |
# File 'lib/ruber/kde_sugar.rb', line 55 def to_yaml opts = {} YAML.quick_emit(self, opts) do |out| out.scalar taguri, to_encoded.to_s, :plain end end |