Class: FileTreeProfiler::File
- Inherits:
-
Object
- Object
- FileTreeProfiler::File
- Defined in:
- lib/file_tree_profiler/file.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#initialize(parent, name) ⇒ File
constructor
A new instance of File.
- #inspect ⇒ Object
- #path ⇒ Object
- #relative_path ⇒ Object
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/file_tree_profiler/file.rb', line 3 def name @name end |
#parent ⇒ Object (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
#inspect ⇒ Object
22 23 24 |
# File 'lib/file_tree_profiler/file.rb', line 22 def inspect "<#{self.class} @name=#{name} #path=#{path}>" end |
#path ⇒ Object
10 11 12 |
# File 'lib/file_tree_profiler/file.rb', line 10 def path ::File.join(parent.path, name) end |
#relative_path ⇒ Object
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 |