Class: Xcflushd::GLIHelpers::GenericURI
- Inherits:
-
Object
- Object
- Xcflushd::GLIHelpers::GenericURI
- Defined in:
- lib/xcflushd/gli_helpers.rb
Overview
URI parsing for GLI
Class Method Summary collapse
Class Method Details
.new(s, default_port = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/xcflushd/gli_helpers.rb', line 38 def self.new(s, default_port = nil) # URI.parse won't correctly parse a URI without a scheme unless SCHEME_RE.match s s = "generic://#{s}" end uri = URI.parse(s) # exit with an error if no host parsed return false unless uri.host if !uri.port && default_port uri.port = default_port end uri.define_singleton_method :to_a do [self] end uri end |