Class: Browser::Event::Message

Inherits:
Browser::Event show all
Defined in:
opal/browser/event/message.rb

Defined Under Namespace

Classes: Definition

Instance Attribute Summary

Attributes inherited from Browser::Event

#callback, #on

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Browser::Event

aliases, #arguments, #arguments=, class_for, create, handlers, handles, #initialize, #name, name_for, new, #off, #prevent, #prevented?, #stop, #stop!, #stopped?, #target

Constructor Details

This class inherits a constructor from Browser::Event

Class Method Details

.construct(name, desc) ⇒ Object


27
28
29
# File 'opal/browser/event/message.rb', line 27

def self.construct(name, desc)
  `new MessageEvent(#{name}, #{desc})`
end

.supported?Boolean

Returns:

  • (Boolean)

8
9
10
# File 'opal/browser/event/message.rb', line 8

def self.supported?
  Browser.supports? 'Event.Message'
end

Instance Method Details

#dataObject


42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'opal/browser/event/message.rb', line 42

def data
  %x{
    if (window.ArrayBuffer && #@native.data instanceof ArrayBuffer) {
      return #{Buffer.new(`#@native.data`)};
    }
    else if (window.Blob && #@native.data instanceof Blob) {
      return #{Blob.new(`#@native.data`)};
    }
    else {
      return #@native.data;
    }
  }
end

#sourceObject


58
59
60
61
62
63
64
65
66
67
68
69
# File 'opal/browser/event/message.rb', line 58

def source
  %x{
    var source = #@native.source;

    if (window.Window && source instanceof window.Window) {
      return #{Window.new(`source`)};
    }
    else {
      return nil;
    }
  }
end