Method: URI::Generic#select

Defined in:
lib/extensions/uri/uri/generic.rb

#select(*components) ⇒ Object

Args

components

Multiple Symbol arguments defined in URI::HTTP

Description

Selects specified components from URI

Usage

require 'uri'

uri = URI.parse('http://myuser:[email protected]/test.rbx')
p uri.select(:userinfo, :host, :path)
# => ["myuser:mypass", "my.example.com", "/test.rbx"]


1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
# File 'lib/extensions/uri/uri/generic.rb', line 1110

def select(*components)
  components.collect do |c|
    if component.include?(c)
      self.send(c)
    else
      raise ArgumentError, 
        "expected of components of #{self.class} (#{self.class.component.join(', ')})"
    end
  end
end