Module: FuzzyURL::URLComponents
- Included in:
- FuzzyURL
- Defined in:
- lib/fuzzy_url/url_components.rb
Overview
FuzzyURL::URLComponents provides getting/setting of URL components on FuzzyURL objects in hash style (e.g. ‘foo`) and method style (e.g. `foo.hostname`). Acceptable URL components are :protocol, :username, :password, :hostname, :port, :path, :query, and :fragment.
Constant Summary collapse
- COMPONENTS =
[:protocol, :username, :password, :hostname, :port, :path, :query, :fragment]
Instance Method Summary collapse
-
#[](component) ⇒ Object
Gets a URL component.
-
#[]=(component, value) ⇒ Object
Sets a URL component.
-
#fragment ⇒ Object
Get the fragment for this FuzzyURL.
-
#fragment=(v) ⇒ Object
Set the fragment for this FuzzyURL.
-
#hostname ⇒ Object
Get the hostname for this FuzzyURL.
-
#hostname=(v) ⇒ Object
Set the hostname for this FuzzyURL.
-
#password ⇒ Object
Get the password for this FuzzyURL.
-
#password=(v) ⇒ Object
Set the password for this FuzzyURL.
-
#path ⇒ Object
Get the path for this FuzzyURL.
-
#path=(v) ⇒ Object
Set the path for this FuzzyURL.
-
#port ⇒ Object
Get the port for this FuzzyURL.
-
#port=(v) ⇒ Object
Set the port for this FuzzyURL.
-
#protocol ⇒ Object
Get the protocol for this FuzzyURL.
-
#protocol=(v) ⇒ Object
Set the protocol for this FuzzyURL.
-
#query ⇒ Object
Get the query for this FuzzyURL.
-
#query=(v) ⇒ Object
Set the query for this FuzzyURL.
-
#username ⇒ Object
Get the username for this FuzzyURL.
-
#username=(v) ⇒ Object
Set the username for this FuzzyURL.
Instance Method Details
#[](component) ⇒ Object
Gets a URL component.
14 15 16 17 18 19 20 21 |
# File 'lib/fuzzy_url/url_components.rb', line 14 def [](component) component_sym = component.to_sym if !COMPONENTS.include?(component_sym) raise ArgumentError, "#{component.inspect} is not a URL component. "+ COMPONENTS.inspect end @components[component_sym] end |
#[]=(component, value) ⇒ Object
Sets a URL component.
24 25 26 27 28 29 30 31 |
# File 'lib/fuzzy_url/url_components.rb', line 24 def []=(component, value) component_sym = component.to_sym if !COMPONENTS.include?(component_sym) raise ArgumentError, "#{component.inspect} is not a URL component. "+ COMPONENTS.inspect end @components[component_sym] = value end |
#fragment ⇒ Object
Get the fragment for this FuzzyURL.
84 |
# File 'lib/fuzzy_url/url_components.rb', line 84 def fragment; self[:fragment] end |
#fragment=(v) ⇒ Object
Set the fragment for this FuzzyURL.
87 |
# File 'lib/fuzzy_url/url_components.rb', line 87 def fragment=(v); self[:fragment]=v end |
#hostname ⇒ Object
Get the hostname for this FuzzyURL.
56 |
# File 'lib/fuzzy_url/url_components.rb', line 56 def hostname; self[:hostname] end |
#hostname=(v) ⇒ Object
Set the hostname for this FuzzyURL.
59 |
# File 'lib/fuzzy_url/url_components.rb', line 59 def hostname=(v); self[:hostname]=v end |
#password ⇒ Object
Get the password for this FuzzyURL.
49 |
# File 'lib/fuzzy_url/url_components.rb', line 49 def password; self[:password] end |
#password=(v) ⇒ Object
Set the password for this FuzzyURL.
52 |
# File 'lib/fuzzy_url/url_components.rb', line 52 def password=(v); self[:password]=v end |
#path ⇒ Object
Get the path for this FuzzyURL.
70 |
# File 'lib/fuzzy_url/url_components.rb', line 70 def path; self[:path] end |
#path=(v) ⇒ Object
Set the path for this FuzzyURL.
73 |
# File 'lib/fuzzy_url/url_components.rb', line 73 def path=(v); self[:path]=v end |
#port ⇒ Object
Get the port for this FuzzyURL.
63 |
# File 'lib/fuzzy_url/url_components.rb', line 63 def port; self[:port] end |
#port=(v) ⇒ Object
Set the port for this FuzzyURL.
66 |
# File 'lib/fuzzy_url/url_components.rb', line 66 def port=(v); self[:port]=v end |
#protocol ⇒ Object
Get the protocol for this FuzzyURL.
35 |
# File 'lib/fuzzy_url/url_components.rb', line 35 def protocol; self[:protocol] end |
#protocol=(v) ⇒ Object
Set the protocol for this FuzzyURL.
38 |
# File 'lib/fuzzy_url/url_components.rb', line 38 def protocol=(v); self[:protocol]=v end |
#query ⇒ Object
Get the query for this FuzzyURL.
77 |
# File 'lib/fuzzy_url/url_components.rb', line 77 def query; self[:query] end |
#query=(v) ⇒ Object
Set the query for this FuzzyURL.
80 |
# File 'lib/fuzzy_url/url_components.rb', line 80 def query=(v); self[:query]=v end |
#username ⇒ Object
Get the username for this FuzzyURL.
42 |
# File 'lib/fuzzy_url/url_components.rb', line 42 def username; self[:username] end |
#username=(v) ⇒ Object
Set the username for this FuzzyURL.
45 |
# File 'lib/fuzzy_url/url_components.rb', line 45 def username=(v); self[:username]=v end |