Class: URI::Generic

Inherits:
Object show all
Defined in:
lib/accessibility/bridge/mri.rb

Overview

accessibility-core extensions to the URI family of classes

Instance Method Summary collapse

Instance Method Details

#lastPathComponentString

Return the last component of the path of the URL

This is intended to help make URI::Generic closer to being a drop-in replacement for NSURL.

Examples:


url = "https://macruby.macosforge.org/files/nightlies/macruby_nightly-latest.pkg"
URI.parse(url).lastPathComponent # => "macruby_nightly-latest.pkg"

Returns:



122
123
124
# File 'lib/accessibility/bridge/mri.rb', line 122

def lastPathComponent
  self.path.split(%r{/+}).last
end

#pathExtensionString

Returns the path extension of a file URL

This is intended to help make URI::Generic closer to being a drop-in replacement for NSURL.

Examples:


url = "https://macruby.macosforge.org/files/nightlies/macruby_nightly-latest.pkg"
URI.parse(url).pathExtension # => "pkg"

Returns:



138
139
140
141
# File 'lib/accessibility/bridge/mri.rb', line 138

def pathExtension
  split = self.path.split '.', -1
  split.size > 1 ? split.last : ''
end

#to_urlURI::Generic

Returns the receiver (since the receiver is already a URI object)

Returns:



106
107
108
# File 'lib/accessibility/bridge/mri.rb', line 106

def to_url
  self
end