Class: Turbo::ScriptMessage
- Inherits:
-
Object
- Object
- Turbo::ScriptMessage
- Defined in:
- lib/turbo/web_view/script_message.rb
Constant Summary collapse
- NAMES =
{ page_loaded: "pageLoaded", page_load_failed: "pageLoadFailed", error_raised: "errorRaised", visit_proposed: "visitProposed", visit_started: "visitStarted", visit_request_started: "visitRequestStarted", visit_request_completed: "visitRequestCompleted", visit_request_failed: "visitRequestFailed", visit_request_finished: "visitRequestFinished", visit_rendered: "visitRendered", visit_completed: "visitCompleted", form_submission_started: "formSubmissionStarted", form_submission_finished: "formSubmissionFinished", page_invalidated: "pageInvalidated", log: "log" }
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #date ⇒ Object
- #identifier ⇒ Object
-
#initialize(name, data) ⇒ ScriptMessage
constructor
A new instance of ScriptMessage.
- #location ⇒ Object
- #options ⇒ Object
- #restorationIdentifier ⇒ Object
-
#timestamp ⇒ Object
Milliseconds since unix epoch as provided by JavaScript Date.now().
Constructor Details
#initialize(name, data) ⇒ ScriptMessage
Returns a new instance of ScriptMessage.
39 40 41 42 |
# File 'lib/turbo/web_view/script_message.rb', line 39 def initialize(name, data) @name = name @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
37 38 39 |
# File 'lib/turbo/web_view/script_message.rb', line 37 def data @data end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
37 38 39 |
# File 'lib/turbo/web_view/script_message.rb', line 37 def name @name end |
Class Method Details
.parse(message) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/turbo/web_view/script_message.rb', line 21 def self.parse() body = .body return unless body rawName = body["name"] return unless rawName name = NAMES.key(rawName) return unless name data = body["data"] return unless data return new(name, data) end |
Instance Method Details
#date ⇒ Object
56 57 58 |
# File 'lib/turbo/web_view/script_message.rb', line 56 def date NSDate.alloc.initWithTimeIntervalSince1970( / 1000.0) end |
#identifier ⇒ Object
44 45 46 47 |
# File 'lib/turbo/web_view/script_message.rb', line 44 def identifier identifier = data["identifier"] identifier if identifier.is_a?(String) end |
#location ⇒ Object
65 66 67 |
# File 'lib/turbo/web_view/script_message.rb', line 65 def location NSURL.alloc.initWithString(data["location"]) if data["location"] end |
#options ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/turbo/web_view/script_message.rb', line 69 def if = data["options"] VisitOptions.alloc.initFromHash() else nil end end |
#restorationIdentifier ⇒ Object
60 61 62 63 |
# File 'lib/turbo/web_view/script_message.rb', line 60 def restorationIdentifier restorationIdentifier = data["restorationIdentifier"] restorationIdentifier if restorationIdentifier.is_a?(String) end |
#timestamp ⇒ Object
Milliseconds since unix epoch as provided by JavaScript Date.now()
50 51 52 53 54 |
# File 'lib/turbo/web_view/script_message.rb', line 50 def #data["timestamp"] as? TimeInterval ?? 0 = data["timestamp"] .to_i || 0 end |