Class: Nanoc3::Item
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#basename_no_extension, #indent, #no_blank_lines, #no_leading_ws, #no_trailing_ws, oxford_comma, #quoted, #reindent, #unindent
Instance Attribute Details
#identifier ⇒ Object
know what you are doing if you set it
20
21
22
|
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 20
def identifier
@identifier
end
|
Class Method Details
.sorted_visible_children ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 8
def sorted_visible_children
@svc ||= begin
proc do |node|
node.children.select{|c| c.nandoc_visible? }.sort_by(&:nandoc_title)
end
end
end
|
Instance Method Details
#nandoc_content_branch? ⇒ Boolean
47
48
49
|
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 47
def nandoc_content_branch?
false end
|
#nandoc_content_leaf? ⇒ Boolean
43
44
45
|
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 43
def nandoc_content_leaf?
nandoc_content_node? end
|
#nandoc_content_node? ⇒ Boolean
39
40
41
|
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 39
def nandoc_content_node?
/\A\/(?:css|js|vendor)\// !~ identifier end
|
#nandoc_sorted_visible_children ⇒ Object
51
52
53
|
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 51
def nandoc_sorted_visible_children
self.class.sorted_visible_children.call(self)
end
|
#nandoc_title ⇒ Object
come up with some title by any means necessary
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 25
def nandoc_title
if @attributes[:title]
@attributes[:title]
elsif ! nandoc_content_node?
identifier
elsif no_ext = basename_no_extension(@attributes[:content_filename])
no_ext.gsub(/[-_]/, ' ') elsif ! (foo = File.basename(@attributes[:content_filename])).empty?
foo
else
identifier == '/' ? 'HOME' : identifier.gsub('/',' - ')
end
end
|
#nandoc_visible? ⇒ Boolean
55
56
57
|
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 55
def nandoc_visible?
!self[:hidden] && path && nandoc_content_node?
end
|