Class: Browser::FileList
- Includes:
- Enumerable
- Defined in:
- lib/browser/file_list.rb
Defined Under Namespace
Classes: File
Instance Method Summary collapse
-
#[](index) ⇒ Browser::FileList::File
The file at the specified index.
-
#each {|file| ... } ⇒ Object
Call the given block for each file in the list.
-
#initialize(native) ⇒ FileList
constructor
A new instance of FileList.
-
#length ⇒ Integer
(also: #size)
The number of files in this list.
-
#to_a ⇒ Object
(also: #to_ary)
Convert this FileList into an array.
-
#to_s ⇒ String
A string representation of this FileList.
Constructor Details
#initialize(native) ⇒ FileList
6 7 8 9 10 11 |
# 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 |
Instance Method Details
#[](index) ⇒ Browser::FileList::File
15 16 17 |
# File 'lib/browser/file_list.rb', line 15 def [] index @files[index] end |
#each {|file| ... } ⇒ Object
Call the given block for each file in the list
28 29 30 31 32 |
# File 'lib/browser/file_list.rb', line 28 def each &block @files.each do |file| block.call file end end |
#length ⇒ Integer Also known as: size
20 21 22 |
# File 'lib/browser/file_list.rb', line 20 def length `#@native.length` end |
#to_a ⇒ Object Also known as: to_ary
Convert this FileList into an array
35 36 37 |
# 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 |
#to_s ⇒ String
41 42 43 |
# File 'lib/browser/file_list.rb', line 41 def to_s @files.to_s end |