Class: Jekyll::AwesomeNav::Node
- Inherits:
-
Object
- Object
- Jekyll::AwesomeNav::Node
- Defined in:
- lib/jekyll/awesome_nav/node.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#path ⇒ Object
Returns the value of attribute path.
-
#target ⇒ Object
Returns the value of attribute target.
-
#title ⇒ Object
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
- .page(dir:, title:, url:, path: nil, filename: nil) ⇒ Object
- .reference(dir:, target:, title: nil) ⇒ Object
- .section(dir:, title: nil, url: nil, children: [], path: nil, filename: nil) ⇒ Object
Instance Method Summary collapse
- #deep_dup ⇒ Object
-
#initialize(type:, dir:, title:, url:, children:, path: nil, filename: nil) ⇒ Node
constructor
A new instance of Node.
- #page? ⇒ Boolean
- #reference? ⇒ Boolean
- #section? ⇒ Boolean
- #with_children(children) ⇒ Object
Constructor Details
#initialize(type:, dir:, title:, url:, children:, path: nil, filename: nil) ⇒ Node
Returns a new instance of Node.
23 24 25 26 27 28 29 30 31 |
# File 'lib/jekyll/awesome_nav/node.rb', line 23 def initialize(type:, dir:, title:, url:, children:, path: nil, filename: nil) @type = type @dir = dir @title = title @url = url @children = Array(children) @path = path @filename = filename end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
7 8 9 |
# File 'lib/jekyll/awesome_nav/node.rb', line 7 def children @children end |
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
7 8 9 |
# File 'lib/jekyll/awesome_nav/node.rb', line 7 def dir @dir end |
#filename ⇒ Object
Returns the value of attribute filename.
6 7 8 |
# File 'lib/jekyll/awesome_nav/node.rb', line 6 def filename @filename end |
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/jekyll/awesome_nav/node.rb', line 6 def path @path end |
#target ⇒ Object
Returns the value of attribute target.
6 7 8 |
# File 'lib/jekyll/awesome_nav/node.rb', line 6 def target @target end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/jekyll/awesome_nav/node.rb', line 6 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/jekyll/awesome_nav/node.rb', line 7 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/jekyll/awesome_nav/node.rb', line 6 def url @url end |
Class Method Details
.page(dir:, title:, url:, path: nil, filename: nil) ⇒ Object
13 14 15 |
# File 'lib/jekyll/awesome_nav/node.rb', line 13 def self.page(dir:, title:, url:, path: nil, filename: nil) new(type: :page, dir: dir, title: title, url: url, children: [], path: path, filename: filename) end |
.reference(dir:, target:, title: nil) ⇒ Object
17 18 19 20 21 |
# File 'lib/jekyll/awesome_nav/node.rb', line 17 def self.reference(dir:, target:, title: nil) node = new(type: :reference, dir: dir, title: title, url: nil, children: []) node.target = target node end |
.section(dir:, title: nil, url: nil, children: [], path: nil, filename: nil) ⇒ Object
9 10 11 |
# File 'lib/jekyll/awesome_nav/node.rb', line 9 def self.section(dir:, title: nil, url: nil, children: [], path: nil, filename: nil) new(type: :section, dir: dir, title: title, url: url, children: children, path: path, filename: filename) end |
Instance Method Details
#deep_dup ⇒ Object
59 60 61 |
# File 'lib/jekyll/awesome_nav/node.rb', line 59 def deep_dup with_children(children.map(&:deep_dup)) end |
#page? ⇒ Boolean
37 38 39 |
# File 'lib/jekyll/awesome_nav/node.rb', line 37 def page? type == :page end |
#reference? ⇒ Boolean
41 42 43 |
# File 'lib/jekyll/awesome_nav/node.rb', line 41 def reference? type == :reference end |
#section? ⇒ Boolean
33 34 35 |
# File 'lib/jekyll/awesome_nav/node.rb', line 33 def section? type == :section end |
#with_children(children) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/jekyll/awesome_nav/node.rb', line 45 def with_children(children) node = self.class.new( type: type, dir: dir, title: title, url: url, children: children, path: path, filename: filename ) node.target = target node end |