Class: Slick::Web::Node
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
- #dir? ⇒ Boolean
- #file? ⇒ Boolean
-
#initialize(parent = nil, name = nil) ⇒ Node
constructor
A new instance of Node.
- #relative_path ⇒ Object
- #root ⇒ Object
Constructor Details
#initialize(parent = nil, name = nil) ⇒ Node
Returns a new instance of Node.
6 7 8 9 |
# File 'lib/slick/web/node.rb', line 6 def initialize(parent = nil, name = nil) @parent = parent @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/slick/web/node.rb', line 4 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
4 5 6 |
# File 'lib/slick/web/node.rb', line 4 def parent @parent end |
Instance Method Details
#dir? ⇒ Boolean
31 32 33 |
# File 'lib/slick/web/node.rb', line 31 def dir? kind_of?(Slick::Web::Dir) end |
#file? ⇒ Boolean
27 28 29 |
# File 'lib/slick/web/node.rb', line 27 def file? kind_of?(Slick::Web::File) end |
#relative_path ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/slick/web/node.rb', line 11 def relative_path @relative_path ||= begin out = [] current = self while current out.unshift(current.name) current = current.parent end out.join('/') end end |