class Path::URI

A wrapper for URI objects.

Attributes

uri[R]

Public Class Methods

new(uri, hints={}) click to toggle source

TODO: only include certain methods from Path (delegate style)

(eg: remove commands that write)
# File lib/epitools/path.rb, line 1636
def initialize(uri, hints={})
  @uri = ::URI.parse(uri)
  self.path = @uri.path
end

Public Instance Methods

host() click to toggle source

…and this is: 'host.com'

# File lib/epitools/path.rb, line 1677
def host; uri.host; end
http?() click to toggle source

`http?` checks for 'http' OR 'https' schemes

Calls superclass method
# File lib/epitools/path.rb, line 1670
def http?
  super or https?
end
inspect() click to toggle source
# File lib/epitools/path.rb, line 1654
def inspect
  "#<Path::URI:#{to_s}>"
end
io(mode="r", &block)
Alias for: open
join(other) click to toggle source
# File lib/epitools/path.rb, line 1695
def join(other)
  Path.new URI.join(path, other).to_s
end
open(mode="r", &block) click to toggle source

…and `path` is /path/filename.ext

# File lib/epitools/path.rb, line 1702
def open(mode="r", &block)
  require 'open-uri'
  if block_given?
    ::URI.open(to_s, mode, &block)
  else
    ::URI.open(to_s, mode)
  end
end
Also aliased as: io
port() click to toggle source

…and this is: 80

# File lib/epitools/path.rb, line 1682
def port; uri.port; end
protocol()
Alias for: scheme
query() click to toggle source

…and this is: {param1: value1, param2: value2, …etc… }

# File lib/epitools/path.rb, line 1687
def query
  if query = uri.query
    query.to_params
  else
    nil
  end
end
read(*args) click to toggle source
# File lib/epitools/path.rb, line 1713
def read(*args)
  open { |io| io.read(*args) }
end
scheme() click to toggle source
# File lib/epitools/path.rb, line 1658
def scheme
  uri.scheme
end
Also aliased as: protocol
to_path() click to toggle source
# File lib/epitools/path.rb, line 1651
def to_path; to_s; end
to_s() click to toggle source

Example:

When this is: host.com:port/path/filename.ext?param1=value1¶m2=value2&…

# File lib/epitools/path.rb, line 1650
def to_s; uri.to_s; end
to_str() click to toggle source
# File lib/epitools/path.rb, line 1652
def to_str; to_s; end
uri?() click to toggle source
# File lib/epitools/path.rb, line 1641
def uri?
  true
end