Sha256: 2ea1cf5c8ce1b6df224977ba31d35dbf4bc9371a8db998183429e7fc23362eaa

Contents?: true

Size: 886 Bytes

Versions: 1

Compression:

Stored size: 886 Bytes

Contents

require 'buffer'

module Browser; module DOM; class Event

class Message < Event
  def self.supported?
    not $$[:MessageEvent].nil?
  end

  class Definition < Definition
    def data=(value)
      `#@native.data = #{value.to_n}`
    end
  end

  def self.create(name, &block)
    new(`new MessageEvent(#{name}, #{Definition.new(&block)})`)
  end

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

  alias_native :origin

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

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

end; end; end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-browser-0.1.0.beta1 opal/browser/dom/event/message.rb