Module: FileSystemEntity::Methods

Defined in:
lib/exegesis/file_system_entity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



18
19
20
# File 'lib/exegesis/file_system_entity.rb', line 18

def name
  @name
end

#parentObject (readonly) Also known as: container

Returns the value of attribute parent.



18
19
20
# File 'lib/exegesis/file_system_entity.rb', line 18

def parent
  @parent
end

Instance Method Details

#basenameObject



21
22
23
# File 'lib/exegesis/file_system_entity.rb', line 21

def basename
  File.basename(name, ext)
end

#extObject Also known as: extension



25
26
27
# File 'lib/exegesis/file_system_entity.rb', line 25

def ext
  @ext || ""
end

#inspectObject



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

def inspect
  "#{self.class.inspect}(#{path.inspect})"
end

#pathObject



10
11
12
# File 'lib/exegesis/file_system_entity.rb', line 10

def path
  File.join(parent.path, name)
end

#visit(visitor) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/exegesis/file_system_entity.rb', line 31

def visit(visitor)
  visitor.on_enter if visitor.respond_to? :on_enter

  visitor.call(self.class, self)

  if respond_to?(:directories)
    directories.each do |dir|
      dir.visit(visitor)
    end
  end

  if respond_to?(:files)
    files.each do |file|
      file.visit(visitor)
    end
  end

  visitor.on_exit if visitor.respond_to? :on_exit
end