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 1651
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 1692
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 1685
def http?
  super or https?
end
inspect() click to toggle source
# File lib/epitools/path.rb, line 1669
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 1710
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 1717
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 1697
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 1702
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 1728
def read(*args)
  open { |io| io.read(*args) }
end
scheme() click to toggle source
# File lib/epitools/path.rb, line 1673
def scheme
  uri.scheme
end
Also aliased as: protocol
to_path() click to toggle source
# File lib/epitools/path.rb, line 1666
def to_path; to_s; end
to_s() click to toggle source

Example:

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

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