Module: Exegesis::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.



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

def name
  @name
end

#parentObject (readonly) Also known as: container

Returns the value of attribute parent.



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

def parent
  @parent
end

Instance Method Details

#basenameObject



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

def basename
  File.basename(name, ext)
end

#extObject Also known as: extension



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

def ext
  @ext || ""
end

#inspectObject



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

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

#pathObject



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

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