Method: UniformResourceIdentifier::Authority#initialize
- Defined in:
- lib/uniform_resource_identifier/authority.rb
#initialize(authority = nil) ⇒ Authority
Returns a new instance of Authority.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/uniform_resource_identifier/authority.rb', line 11 def initialize(=nil) if .respond_to?(:to_str) = Parser.parse() port = [:port].blank? ? nil : [:port].to_i if .has_key?(:port) @user_info = UserInfo.parse([:user_info]) if .has_key?(:user_info) @host = Host.parse([:host]) if .has_key?(:host) @port = port elsif .respond_to?(:to_hash) = .to_hash.symbolize_keys port = [:port].blank? ? nil : [:port].to_i if .has_key?(:port) @user_info = UserInfo.parse([:user_info]) if .has_key?(:user_info) @host = Host.parse([:host]) if .has_key?(:host) @port = port else raise(TypeError, "authority must either be a String or a Hash") unless .nil? end end |