Sha256: 7cf214d263c23ebd47e1ad7a2f5af90e25447daee733b88ba31689c80b99786c
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
require 'promise' module Bowser class FileList include Enumerable def initialize native @native = `#{native} || []` end def [] index if index < length && index >= 0 File.new(`#@native[index]`) end end def length `#@native.length` end alias size length def each &block length.times.each do |i| block.call self[i] end end def to_a map { |file| file } end alias to_ary to_a class File def initialize native @native = native end def name `#@native.name` end def size `#@native.size` end def type `#@native.type` end def last_modified `#@native.lastModifiedDate` end def read promise = Promise.new reader = Native(`new FileReader()`) reader[:onload] = proc do promise.resolve reader.result end reader[:onerror] = proc do promise.reject reader.result end reader.readAsBinaryString(`#@native`) promise end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bowser-0.1.4 | opal/bowser/file_list.rb |
bowser-0.1.3 | opal/bowser/file_list.rb |