Class: Dommy::Navigator
- Inherits:
-
Object
- Object
- Dommy::Navigator
- Defined in:
- lib/dommy/navigator.rb
Overview
‘window.navigator` — exposes browser-agent metadata plus `clipboard` / `permissions` sub-objects. Dommy returns sensible defaults (Dommy as user agent, “en” language, online=true) that tests can override.
Constant Summary collapse
- DEFAULT_USER_AGENT =
"Mozilla/5.0 (Dommy) Ruby"
Instance Attribute Summary collapse
-
#clipboard ⇒ Object
readonly
Returns the value of attribute clipboard.
-
#cookie_enabled ⇒ Object
Returns the value of attribute cookie_enabled.
-
#language ⇒ Object
Returns the value of attribute language.
-
#languages ⇒ Object
Returns the value of attribute languages.
-
#on_line ⇒ Object
Returns the value of attribute on_line.
-
#permissions ⇒ Object
readonly
Returns the value of attribute permissions.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
-
#vendor ⇒ Object
Returns the value of attribute vendor.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(k, v) ⇒ Object
- #__js_get__(key) ⇒ Object
- #__js_set__(_key, _value) ⇒ Object
-
#initialize(window) ⇒ Navigator
constructor
A new instance of Navigator.
Constructor Details
#initialize(window) ⇒ Navigator
Returns a new instance of Navigator.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dommy/navigator.rb', line 13 def initialize(window) @window = window @user_agent = DEFAULT_USER_AGENT @language = "en" @languages = ["en"].freeze @platform = "Dommy" @vendor = "Dommy" @on_line = true @cookie_enabled = true @clipboard = Clipboard.new(window) @permissions = Permissions.new(window) end |
Instance Attribute Details
#clipboard ⇒ Object (readonly)
Returns the value of attribute clipboard.
26 27 28 |
# File 'lib/dommy/navigator.rb', line 26 def clipboard @clipboard end |
#cookie_enabled ⇒ Object
Returns the value of attribute cookie_enabled.
11 12 13 |
# File 'lib/dommy/navigator.rb', line 11 def @cookie_enabled end |
#language ⇒ Object
Returns the value of attribute language.
11 12 13 |
# File 'lib/dommy/navigator.rb', line 11 def language @language end |
#languages ⇒ Object
Returns the value of attribute languages.
11 12 13 |
# File 'lib/dommy/navigator.rb', line 11 def languages @languages end |
#on_line ⇒ Object
Returns the value of attribute on_line.
11 12 13 |
# File 'lib/dommy/navigator.rb', line 11 def on_line @on_line end |
#permissions ⇒ Object (readonly)
Returns the value of attribute permissions.
26 27 28 |
# File 'lib/dommy/navigator.rb', line 26 def @permissions end |
#platform ⇒ Object
Returns the value of attribute platform.
11 12 13 |
# File 'lib/dommy/navigator.rb', line 11 def platform @platform end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
11 12 13 |
# File 'lib/dommy/navigator.rb', line 11 def user_agent @user_agent end |
#vendor ⇒ Object
Returns the value of attribute vendor.
11 12 13 |
# File 'lib/dommy/navigator.rb', line 11 def vendor @vendor end |
Instance Method Details
#[](key) ⇒ Object
28 29 30 |
# File 'lib/dommy/navigator.rb', line 28 def [](key) __js_get__(key.to_s) end |
#[]=(k, v) ⇒ Object
32 33 34 |
# File 'lib/dommy/navigator.rb', line 32 def []=(k, v) __js_set__(k.to_s, v) end |
#__js_get__(key) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dommy/navigator.rb', line 36 def __js_get__(key) case key when "userAgent" @user_agent when "language" @language when "languages" @languages when "platform" @platform when "vendor" @vendor when "onLine" @on_line when "cookieEnabled" @cookie_enabled when "clipboard" @clipboard when "permissions" @permissions end end |
#__js_set__(_key, _value) ⇒ Object
59 60 61 |
# File 'lib/dommy/navigator.rb', line 59 def __js_set__(_key, _value) nil end |