Class: Browser::Location
- Includes:
- NativeCachedWrapper
- Defined in:
- opal/browser/location.rb
Overview
Allows manipulation of a location, usually from Window and DOM::Document.
Instance Attribute Summary collapse
-
#fragment ⇒ String
The hash fragment of the location URI.
-
#host ⇒ String
The host part of the location URI.
-
#path ⇒ String
The path part of the location URI.
-
#port ⇒ Integer
The port part of the location URI.
-
#query ⇒ String
The query part of the location URI.
-
#scheme ⇒ String
The scheme part of the location URI.
-
#uri ⇒ String
The whole location URI.
Instance Method Summary collapse
-
#assign(url) ⇒ Object
Change the location.
-
#full_path ⇒ Object
Returns the full path of the location URI, including the query string and fragment, eg.
-
#reload(force = false) ⇒ Object
Reload the page.
-
#replace(url) ⇒ Object
Replace the current URL.
-
#to_s ⇒ Object
Convert the location to a string.
Methods included from NativeCachedWrapper
#restricted?, #set_native_reference
Instance Attribute Details
#fragment ⇒ String
Returns the hash fragment of the location URI.
38 |
# File 'opal/browser/location.rb', line 38 alias_native :fragment, :hash |
#host ⇒ String
Returns the host part of the location URI.
43 |
# File 'opal/browser/location.rb', line 43 alias_native :host |
#path ⇒ String
Returns the path part of the location URI.
53 |
# File 'opal/browser/location.rb', line 53 alias_native :path, :pathname |
#port ⇒ Integer
Returns the port part of the location URI.
58 |
# File 'opal/browser/location.rb', line 58 alias_native :port |
#query ⇒ String
Returns the query part of the location URI.
68 |
# File 'opal/browser/location.rb', line 68 alias_native :query, :search |
#scheme ⇒ String
Returns the scheme part of the location URI.
63 |
# File 'opal/browser/location.rb', line 63 alias_native :scheme, :protocol |
#uri ⇒ String
Returns the whole location URI.
48 |
# File 'opal/browser/location.rb', line 48 alias_native :uri, :href |
Instance Method Details
#assign(url) ⇒ Object
Change the location.
13 14 15 |
# File 'opal/browser/location.rb', line 13 def assign(url) `#@native.assign(#{url.to_s})` end |
#full_path ⇒ Object
Returns the full path of the location URI, including the query string and fragment, eg. /site?a=b#c
73 74 75 |
# File 'opal/browser/location.rb', line 73 def full_path path + query + fragment end |
#reload(force = false) ⇒ Object
Reload the page.
27 28 29 |
# File 'opal/browser/location.rb', line 27 def reload(force = false) `#@native.reload(force)` end |
#replace(url) ⇒ Object
Replace the current URL.
20 21 22 |
# File 'opal/browser/location.rb', line 20 def replace(url) `#@native.replace(#{url.to_s})` end |
#to_s ⇒ Object
Convert the location to a string.
32 33 34 |
# File 'opal/browser/location.rb', line 32 def to_s `#@native.toString()` end |