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

[View source]

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

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

#children_namesObject

[View source]

27
28
29
# File 'lib/listed_directory.rb', line 27

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

#children_pathsObject

[View source]

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

def children_paths
  children_names.map {|n| File.join(full_path, n)}
end

#directory?Boolean

Returns:

  • (Boolean)
[View source]

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

def directory?
  true
end

#exists?Boolean

Returns:

  • (Boolean)
[View source]

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

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

#file?Boolean

Returns:

  • (Boolean)
[View source]

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

def file?
  false # yeah..!
end

#icon_nameObject

[View source]

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

def icon_name
  'folder'
end

#refreshObject

[View source]

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

def refresh
  super
  #remove_not_existing_files
  add_new_files
end

#sortObject

[View source]

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

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