Class: FileTreeProfiler::File

Inherits:
Object
  • Object
show all
Defined in:
lib/file_tree_profiler/file.rb

Direct Known Subclasses

DataFile, DirFile

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, name) ⇒ File

Returns a new instance of File.



5
6
7
8
# File 'lib/file_tree_profiler/file.rb', line 5

def initialize parent, name
  @parent = parent
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/file_tree_profiler/file.rb', line 3

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



3
4
5
# File 'lib/file_tree_profiler/file.rb', line 3

def parent
  @parent
end

Instance Method Details

#inspectObject



22
23
24
# File 'lib/file_tree_profiler/file.rb', line 22

def inspect
  "<#{self.class} @name=#{name} #path=#{path}>"
end

#pathObject



10
11
12
# File 'lib/file_tree_profiler/file.rb', line 10

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

#relative_pathObject



14
15
16
17
18
19
20
# File 'lib/file_tree_profiler/file.rb', line 14

def relative_path
  if parent.respond_to? :parent
    ::File.join(parent.relative_path, name)
  else
    '/'
  end
end