Class: TTY::Tree::Node Private
- Inherits:
-
Object
- Object
- TTY::Tree::Node
- Extended by:
- Forwardable
- Defined in:
- lib/tty/tree/node.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A representation of tree node
Direct Known Subclasses
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
private
The directory depth.
-
#name ⇒ Object
readonly
private
The base name for the directory or file.
-
#parent ⇒ Object
readonly
private
The parent directory path.
-
#path ⇒ Object
readonly
private
The current path.
-
#prefix ⇒ Object
readonly
private
The require path prefix.
-
#stat ⇒ Object
readonly
private
The file stat.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?) private
- #full_path ⇒ Object private
- #hidden? ⇒ Boolean private
-
#initialize(path, parent, prefix, level) ⇒ Node
constructor
private
A new instance of Node.
- #leaf? ⇒ Boolean private
- #root? ⇒ Boolean private
- #to_s ⇒ Object private
Constructor Details
#initialize(path, parent, prefix, level) ⇒ Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Node.
36 37 38 39 40 41 42 |
# File 'lib/tty/tree/node.rb', line 36 def initialize(path, parent, prefix, level) @path = Pathname.new(path) @name = @path.basename @parent = Pathname.new(parent) @prefix = prefix @level = level end |
Instance Attribute Details
#level ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The directory depth
25 26 27 |
# File 'lib/tty/tree/node.rb', line 25 def level @level end |
#name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The base name for the directory or file
16 17 18 |
# File 'lib/tty/tree/node.rb', line 16 def name @name end |
#parent ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The parent directory path
19 20 21 |
# File 'lib/tty/tree/node.rb', line 19 def parent @parent end |
#path ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The current path
31 32 33 |
# File 'lib/tty/tree/node.rb', line 31 def path @path end |
#prefix ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The require path prefix
22 23 24 |
# File 'lib/tty/tree/node.rb', line 22 def prefix @prefix end |
#stat ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The file stat
28 29 30 |
# File 'lib/tty/tree/node.rb', line 28 def stat @stat end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 |
# File 'lib/tty/tree/node.rb', line 65 def ==(other) other.is_a?(self.class) && other.state_attrs == state_attrs end |
#full_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 47 |
# File 'lib/tty/tree/node.rb', line 44 def full_path return parent if name.to_s.empty? parent.join(name) end |
#hidden? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
53 54 55 |
# File 'lib/tty/tree/node.rb', line 53 def hidden? name.to_s.start_with?('.') end |
#leaf? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
57 58 59 |
# File 'lib/tty/tree/node.rb', line 57 def leaf? false end |
#root? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 |
# File 'lib/tty/tree/node.rb', line 49 def root? parent.to_s.empty? end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 |
# File 'lib/tty/tree/node.rb', line 61 def to_s @name end |