Class: Wiki::Yggdrasil::Yggdrasil
- Inherits:
-
Object
- Object
- Wiki::Yggdrasil::Yggdrasil
- Defined in:
- lib/wiki/yggdrasil.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #children(depth: 4, article_children: self.root.child_links) ⇒ Object
-
#initialize(uri:) ⇒ Yggdrasil
constructor
A new instance of Yggdrasil.
Constructor Details
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
8 9 10 |
# File 'lib/wiki/yggdrasil.rb', line 8 def root @root end |
Instance Method Details
#children(depth: 4, article_children: self.root.child_links) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/wiki/yggdrasil.rb', line 15 def children(depth: 4, article_children: self.root.child_links) get_children = lambda do |depth, article_children| article_children.map do |uri| article = Wiki::Yggdrasil::Article.new(uri: uri) if (depth == 1) { name: article.name, children: [], } else { name: article.name, children: get_children.call(depth - 1, article.child_links), } end end end @children ||= { name: self.root.name, children: get_children.call(depth, article_children) } end |