Class: ListedDirectory

Inherits:
ListedFile show all
Defined in:
lib/listed_directory.rb

Instance Attribute Summary

Attributes inherited from ListedFile

#full_path, #name, #status

Instance Method Summary collapse

Methods inherited from ListedFile

create, #file_or_directory?, #initialize, #show!

Methods inherited from ActiveWindow::ListedItem

build, #file_or_directory?, #hide!, #icon, #initialize, #matches?, #message?, modify_icon, new_by_iter, new_by_reference, #reference, #reference=, #separator?, #show!, #to_s, #visible?

Constructor Details

This class inherits a constructor from ListedFile

Instance Method Details

#add_new_filesObject

Find files to add



35
36
37
38
39
40
41
42
43
# File 'lib/listed_directory.rb', line 35

def add_new_files
  begin
    children_paths.each do |file_path|
      tree << file_path
    end
  rescue Errno::ENOENT, Errno::EACCES
  end
  @traversed = true
end

#children_namesObject



29
30
31
# File 'lib/listed_directory.rb', line 29

def children_names
  Dir.entries(full_path).select {|p| p !~ /^\./ }
end

#children_pathsObject



23
24
25
26
27
# File 'lib/listed_directory.rb', line 23

def children_paths
  children_names.map {|n| File.join(full_path, n)}
rescue Errno::ENOENT, Errno::EACCES
  []
end

#directory?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/listed_directory.rb', line 11

def directory?
  true
end

#exists?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/listed_directory.rb', line 14

def exists?
  full_path && ::File.directory?(full_path)
end

#file?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/listed_directory.rb', line 8

def file?
  false # yeah..!
end

#icon_nameObject



5
6
7
# File 'lib/listed_directory.rb', line 5

def icon_name
  'folder'
end

#refreshObject



17
18
19
20
21
# File 'lib/listed_directory.rb', line 17

def refresh
  super
  #remove_not_existing_files
  add_new_files
end

#sortObject



2
3
4
# File 'lib/listed_directory.rb', line 2

def sort
  "1-#{name}-1"
end