class Browser::FileList::File
An individual item in a FileList
Attributes
data[R]
Public Class Methods
new(native)
click to toggle source
@param native [JS] the native File
object to wrap
# File lib/browser/file_list.rb, line 50 def initialize native @native = native @data = nil end
Public Instance Methods
last_modified()
click to toggle source
@return [Time] the timestamp of the file
# File lib/browser/file_list.rb, line 71 def last_modified `#@native.lastModifiedDate` end
name()
click to toggle source
@return [String] the filename
# File lib/browser/file_list.rb, line 56 def name `#@native.name` end
read()
click to toggle source
Read the file from disk into memory
@return [Promise] a promise that resolves when finished loading and
rejects if an error occurs while loading.
# File lib/browser/file_list.rb, line 79 def read promise = Promise.new reader = FileReader.new reader.on :load do result = reader.result @data = result promise.resolve result end reader.on :error do promise.reject reader.result end reader.read_as_binary_string self promise end
size()
click to toggle source
@return [Integer] the size of this file on disk
# File lib/browser/file_list.rb, line 61 def size `#@native.size` end
to_n()
click to toggle source
Convert to the native object
@return [JS.HTMLElement] the underlying native element
# File lib/browser/file_list.rb, line 101 def to_n @native end
type()
click to toggle source
@return [String] the MIME type of the file, detected by the browser
# File lib/browser/file_list.rb, line 66 def type `#@native.type` end