Sha256: e2571939f7f1130a065c0214fff962f9c42dcf60d54cf96aac154fd451677853

Contents?: true

Size: 503 Bytes

Versions: 2

Compression:

Stored size: 503 Bytes

Contents

module WebMidi
  class Access
    include Native

    def initialize(access)
      super(access)
    end

    def inputs
      values_from_iterator(Input, `#{@native}.inputs`)
    end

    def outputs
      values_from_iterator(Output, `#{@native}.outputs`)
    end

    def values_from_iterator(clazz, iterator)
      values = `#{iterator}.values()`
      size = `#{iterator}.size`
      size.times.inject([]) do |out, _i|
        out << clazz.new(`#{values}.next().value`)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-web-midi-0.0.2 opal/web_midi/access.rb
opal-web-midi-0.0.1 opal/web_midi/access.rb