Class: Dire::Dir

Inherits:
Node
  • Object
show all
Defined in:
lib/dire/dir.rb

Constant Summary collapse

-> (root, nodes, path) {}
@@invalid_path_handler =
-> (root, nodes, path) {}

Instance Attribute Summary

Attributes inherited from Node

#path, #root

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#get, #initialize, #parent, #to_s, #type

Constructor Details

This class inherits a constructor from Dire::Node

Class Method Details



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

def self.invalid_link_handler= lambda
  @@invalid_link_handler = lambda
end

.invalid_path_handler=(lambda) ⇒ Object



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

def self.invalid_path_handler= lambda
  @@invalid_path_handler = lambda
end

Instance Method Details

#dirsObject



15
16
17
# File 'lib/dire/dir.rb', line 15

def dirs
  nodes.select { |i| i.absolute_path.directory? }
end

#filesObject



19
20
21
# File 'lib/dire/dir.rb', line 19

def files
  nodes.select { |i| not i.absolute_path.directory? }
end

#listObject



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

def list
  dirs + files
end

#root?Boolean

Returns:

  • (Boolean)


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

def root?
  not parent
end

#validate!Object



31
32
33
# File 'lib/dire/dir.rb', line 31

def validate!
  super && validate_type!('directory')
end