class Browser::FileList
Public Class Methods
new(native)
click to toggle source
@param native [JS] the native FileList
object to wrap
# File lib/browser/file_list.rb, line 6 def initialize native @native = `#{native} || []` @files = length.times.each_with_object([]) { |index, array| array[index] = File.new(`#@native[index]`) } end
Public Instance Methods
[](index)
click to toggle source
@param index [Integer] the index of the file in the list @return [Browser::FileList::File] the file at the specified index
# File lib/browser/file_list.rb, line 15 def [] index @files[index] end
each(&block)
click to toggle source
Call the given block for each file in the list
@yieldparam file [Browser::FileList::File]
# File lib/browser/file_list.rb, line 28 def each &block @files.each do |file| block.call file end end
length()
click to toggle source
@return [Integer] the number of files in this list
# File lib/browser/file_list.rb, line 20 def length `#@native.length` end
Also aliased as: size
to_a()
click to toggle source
Convert this FileList
into an array
# File lib/browser/file_list.rb, line 35 def to_a @files.dup # Don't return a value that can mutate our internal state end
Also aliased as: to_ary
to_s()
click to toggle source
@return [String] a string representation of this FileList
# File lib/browser/file_list.rb, line 41 def to_s @files.to_s end