Sha256: 10337d7ef23e04dd8ce16a9df03dd9b5adf4e27c36d2075a74d1e5dd7122cb3e

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

module Browser

class Location
  include Native

  # Change the location.
  #
  # @param url [String, #to_s] the URL to go to
  def assign(url)
    `#@native.assign(#{url.to_s})`
  end

  # Replace the current URL.
  #
  # @param url [String, #to_s] the URL to go to
  def replace(url)
    `#@native.replace(#{url.to_s})`
  end

  # Reload the page.
  #
  # @param force [Boolean] whether to force the reload
  def reload(force = false)
    `#@native.reload(force)`
  end

  # Convert the location to a string.
  def to_s
    `#@native.toString()`
  end

  # @!attribute fragment
  # @return [String] the hash fragment of the location URI
  alias_native :fragment, :hash
  alias_native :fragment=, :hash=

  # @!attribute host
  # @return [String] the host part of the location URI
  alias_native :host
  alias_native :host=

  # @!attribute uri
  # @return [String] the whole location URI
  alias_native :uri, :href
  alias_native :uri=, :href=

  # @!attribute path
  # @return [String] the path part of the location URI
  alias_native :path, :pathname
  alias_native :path=, :pathname=

  # @!attribute port
  # @return [Integer] the port part of the location URI
  alias_native :port
  alias_native :port=

  # @!attribute scheme
  # @return [String] the scheme part of the location URI
  alias_native :scheme, :protocol
  alias_native :scheme=, :protocol=

  # @!attribute query
  # @return [String] the query part of the location URI
  alias_native :query, :search
  alias_native :query=, :search=
end

class Window
  # Get the {Location} object for this window.
  #
  # @return [Location]
  def location
    Location.new(`#@native.location`) if `#@native.location`
  end
end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-browser-0.1.0.beta1 opal/browser/location.rb