Method: Addressable::URI#initialize
- Defined in:
- lib/addressable/uri.rb
#initialize(options = {}) ⇒ Addressable::URI
Creates a new uri object from component parts.
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 |
# File 'lib/addressable/uri.rb', line 830 def initialize(={}) if .has_key?(:authority) if (.keys & [:userinfo, :user, :password, :host, :port]).any? raise ArgumentError, "Cannot specify both an authority and any of the components " + "within the authority." end end if .has_key?(:userinfo) if (.keys & [:user, :password]).any? raise ArgumentError, "Cannot specify both a userinfo and either the user or password." end end reset_ivs defer_validation do # Bunch of crazy logic required because of the composite components # like userinfo and authority. self.scheme = [:scheme] if [:scheme] self.user = [:user] if [:user] self.password = [:password] if [:password] self.userinfo = [:userinfo] if [:userinfo] self.host = [:host] if [:host] self.port = [:port] if [:port] self. = [:authority] if [:authority] self.path = [:path] if [:path] self.query = [:query] if [:query] self.query_values = [:query_values] if [:query_values] self.fragment = [:fragment] if [:fragment] end to_s # force path validation end |