Class: NanDoc::Helpers::NanDocHelpers::SiteMap Private
- Inherits:
-
Object
- Object
- NanDoc::Helpers::NanDocHelpers::SiteMap
- Extended by:
- BlockAttrAccessor, SharedAttrReader
- Includes:
- Glyphs, SecretParent
- Defined in:
- lib/nandoc/helpers/site-map.rb
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.
Defined Under Namespace
Modules: Glyphs
Constant Summary
Constants included from Glyphs
Glyphs::ArcUpL, Glyphs::Blank, Glyphs::DashQV, Glyphs::DownLf, Glyphs::DownRt, Glyphs::HvVert, Glyphs::HvVtLf, Glyphs::UpLeft, Glyphs::UpRite, Glyphs::UseThisForBlanks, Glyphs::VertLf, Glyphs::VertRt, Glyphs::Vertic, Glyphs::VtHori
Instance Attribute Summary collapse
- #glyphs ⇒ Object private
- #is_first ⇒ Object private
- #is_last ⇒ Object private
- #item ⇒ Object private
- #level ⇒ Object readonly private
- #root_identifier ⇒ Object private
- #tab ⇒ Object private
- #tabs ⇒ Object private
Attributes included from BlockAttrAccessor
Class Method Summary collapse
- .next_unique_name ⇒ Object private
- .singleton(name, binding, &block) ⇒ Object private
Instance Method Summary collapse
- #children_populate_recursive(cx) ⇒ Object private
- #init_child(parent, item) ⇒ Object private
- #init_root(binding, &block) ⇒ Object private
-
#initialize ⇒ SiteMap
constructor
private
A new instance of SiteMap.
- #merge_opts(opts) ⇒ Object private
-
#render_children(opts = {}) ⇒ String
private
Chunk of <li’s> for eg.
-
#render_parent(&block) ⇒ String
private
<ul> for e.g.
Methods included from SharedAttrReader
Methods included from BlockAttrAccessor
Methods included from Glyphs
#glyphs_right, #glyphs_right_for_child
Methods included from SecretParent
Constructor Details
#initialize ⇒ SiteMap
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 SiteMap.
37 38 39 |
# File 'lib/nandoc/helpers/site-map.rb', line 37 def initialize @tab = ' ' end |
Instance Attribute Details
#glyphs ⇒ 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.
40 41 42 |
# File 'lib/nandoc/helpers/site-map.rb', line 40 def glyphs @glyphs end |
#is_first ⇒ 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.
40 41 42 |
# File 'lib/nandoc/helpers/site-map.rb', line 40 def is_first @is_first end |
#is_last ⇒ 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.
40 41 42 |
# File 'lib/nandoc/helpers/site-map.rb', line 40 def is_last @is_last end |
#item ⇒ 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.
40 41 42 |
# File 'lib/nandoc/helpers/site-map.rb', line 40 def item @item end |
#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.
42 43 44 |
# File 'lib/nandoc/helpers/site-map.rb', line 42 def level @level end |
#root_identifier ⇒ 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.
40 41 42 |
# File 'lib/nandoc/helpers/site-map.rb', line 40 def root_identifier @root_identifier end |
#tab ⇒ 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.
40 41 42 |
# File 'lib/nandoc/helpers/site-map.rb', line 40 def tab @tab end |
#tabs ⇒ 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.
40 41 42 |
# File 'lib/nandoc/helpers/site-map.rb', line 40 def tabs @tabs end |
Class Method Details
.next_unique_name ⇒ 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.
25 26 27 28 |
# File 'lib/nandoc/helpers/site-map.rb', line 25 def next_unique_name @next_unique_name += 1 @next_unique_name end |
.singleton(name, binding, &block) ⇒ 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.
29 30 31 32 33 34 35 |
# File 'lib/nandoc/helpers/site-map.rb', line 29 def singleton(name, binding, &block) @singletons[name] ||= begin sing = new sing.init_root(binding, &block) sing end end |
Instance Method Details
#children_populate_recursive(cx) ⇒ 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.
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/nandoc/helpers/site-map.rb', line 65 def children_populate_recursive cx if cx.any? # keep our @children nil unless we have any children last_idx = cx.size - 1 @children = cx.each.with_index.map do |item, idx| map = self.class.new map.is_first = idx == 0 map.is_last = idx == last_idx map.init_child self, item map end end end |
#init_child(parent, item) ⇒ 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.
56 57 58 59 60 61 62 63 64 |
# File 'lib/nandoc/helpers/site-map.rb', line 56 def init_child parent, item self.parent = parent @item = item self.shared = parent.shared # this does a lot, see SharedAttrReader @level = parent.level + 1 @tabs = parent.tabs + 1 cx = children_proc.call(@item) children_populate_recursive cx end |
#init_root(binding, &block) ⇒ 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.
47 48 49 50 51 52 53 54 55 |
# File 'lib/nandoc/helpers/site-map.rb', line 47 def init_root binding, &block block.call(self) @is_first = @is_last = true @level = 0 @item = nil @tabs ||= 0 root = eval('@items',binding).find{|x| x.identifier == root_identifier} children_populate_recursive [root] end |
#merge_opts(opts) ⇒ 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.
78 79 80 81 82 |
# File 'lib/nandoc/helpers/site-map.rb', line 78 def merge_opts opts fail("just for setting tabs for now") unless opts.keys == [:tabs] @tabs = opts[:tabs] opts end |
#render_children(opts = {}) ⇒ String
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 chunk of <li’s> for eg.
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/nandoc/helpers/site-map.rb', line 102 def render_children opts={} these = @children.map do |map| map.merge_opts opts h1 = render_child_proc.call(map) h2 = map.reindent(h1) h3 = h2.strip h3 end last = @children.last hz = these.join("\n" + last.tab * last.tabs) if last hz end |
#render_parent(&block) ⇒ String
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 <ul> for e.g. Sets block if given.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/nandoc/helpers/site-map.rb', line 85 def render_parent &block if block_given? @render_parent_proc = block class << self attr_accessor :render_parent_proc end nil elsif @children.nil? nil else h1 = render_parent_proc.call(self) h2 = reindent(h1).strip h2 end end |