Class: Browser::Navigator

Inherits:
Object show all
Includes:
Native
Defined in:
opal/browser/navigator.rb

Overview

Representation of the navigator application.

Defined Under Namespace

Classes: MimeType, Plugin, Plugins, Product, Vendor, Version

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#codeString (readonly)

Returns the browser code name.

Returns:

  • (String)

    the browser code name



88
# File 'opal/browser/navigator.rb', line 88

alias_native :code, :appCodeName

#languageString (readonly)

Returns the browser language.

Returns:

  • (String)

    the browser language



110
# File 'opal/browser/navigator.rb', line 110

alias_native :language

#mime_typesNative::Array<MimeType> (readonly)

Returns the supported MIME types.

Returns:

  • (Native::Array<MimeType>)

    the supported MIME types



114
115
116
117
118
# File 'opal/browser/navigator.rb', line 114

def mime_types
  Native::Array.new `#@native.mimeTypes`, get: :item, named: :namedItem do |m|
    MimeType.new(m)
  end
end

#nameString (readonly)

Returns the browser name.

Returns:

  • (String)

    the browser name



92
# File 'opal/browser/navigator.rb', line 92

alias_native :name, :appName

#operating_systemString (readonly) Also known as: os

Returns the operating system the browser is running on.

Returns:

  • (String)

    the operating system the browser is running on



127
# File 'opal/browser/navigator.rb', line 127

alias_native :operating_system, :oscpu

#platformString (readonly)

Returns the platform the browser is running on.

Returns:

  • (String)

    the platform the browser is running on



133
# File 'opal/browser/navigator.rb', line 133

alias_native :platform

#pluginsPlugins (readonly)

Returns the enabled plugins.

Returns:

  • (Plugins)

    the enabled plugins



137
138
139
# File 'opal/browser/navigator.rb', line 137

def plugins
  Plugins.new(`#@native.plugins`)
end

#productProduct (readonly)

Returns the product name and version.

Returns:

  • (Product)

    the product name and version



143
144
145
# File 'opal/browser/navigator.rb', line 143

def product
  Product.new(`#@native.product`, `#@native.productSub`)
end

#user_agentString (readonly)

Returns the browser's user agent.

Returns:

  • (String)

    the browser's user agent



149
# File 'opal/browser/navigator.rb', line 149

alias_native :user_agent, :userAgent

#vendorVendor (readonly)

Returns the vendor name and version.

Returns:

  • (Vendor)

    the vendor name and version



153
154
155
# File 'opal/browser/navigator.rb', line 153

def vendor
  Vendor.new(`#@native.vendor`, `#@native.vendorSub`)
end

#versionVersion (readonly)

Returns the browser version.

Returns:

  • (Version)

    the browser version



96
97
98
# File 'opal/browser/navigator.rb', line 96

def version
  Version.new(`#@native.appVersion`, `#@native.appMinorVersion`, `#@native.buildID`)
end

Instance Method Details

#java?Boolean

Check if Java is enabled.

Returns:

  • (Boolean)


158
159
160
161
162
# File 'opal/browser/navigator.rb', line 158

def java?
  `#@native.javaEnabled()`
rescue
  false
end

#offline?Boolean

Check if the browser is in offline mode.

Returns:

  • (Boolean)


121
122
123
# File 'opal/browser/navigator.rb', line 121

def offline?
  `!#@native.onLine`
end

#track?Boolean

Check if DNT is disabled.

Returns:

  • (Boolean)


104
105
106
# File 'opal/browser/navigator.rb', line 104

def track?
  `!#@native.doNotTrack`
end