Class: Dommy::MessageEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/dommy/message_channel.rb

Overview

‘MessageEvent` — payload of `message` events on MessagePort / BroadcastChannel / WebSocket / EventSource.

Instance Attribute Summary collapse

Attributes inherited from Event

#type

Instance Method Summary collapse

Methods inherited from Event

#__js_call__, #__js_set__, #__prepare_for_dispatch__, #__record_path__, #__set_current_target__, #bubbles?, #default_prevented?, #immediate_propagation_stopped?, #init_event, #propagation_stopped?

Constructor Details

#initialize(type, init = nil) ⇒ MessageEvent

Returns a new instance of MessageEvent.



133
134
135
136
137
138
139
140
# File 'lib/dommy/message_channel.rb', line 133

def initialize(type, init = nil)
  super
  @data = read_init(init, "data")
  @origin = (read_init(init, "origin") || "").to_s
  @last_event_id = (read_init(init, "lastEventId") || "").to_s
  @source = read_init(init, "source")
  @ports = read_init(init, "ports") || []
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



142
143
144
# File 'lib/dommy/message_channel.rb', line 142

def data
  @data
end

#last_event_idObject (readonly)

Returns the value of attribute last_event_id.



142
143
144
# File 'lib/dommy/message_channel.rb', line 142

def last_event_id
  @last_event_id
end

#originObject (readonly)

Returns the value of attribute origin.



142
143
144
# File 'lib/dommy/message_channel.rb', line 142

def origin
  @origin
end

#portsObject (readonly)

Returns the value of attribute ports.



142
143
144
# File 'lib/dommy/message_channel.rb', line 142

def ports
  @ports
end

#sourceObject (readonly)

Returns the value of attribute source.



142
143
144
# File 'lib/dommy/message_channel.rb', line 142

def source
  @source
end

Instance Method Details

#__js_get__(key) ⇒ Object



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/dommy/message_channel.rb', line 144

def __js_get__(key)
  case key
  when "data"
    @data
  when "origin"
    @origin
  when "lastEventId"
    @last_event_id
  when "source"
    @source
  when "ports"
    @ports
  else
    super
  end
end