add_child(c)
click to toggle source
def add_child(c)
@children.push c
end
chapter?()
click to toggle source
each_child(&block)
click to toggle source
def each_child(&block)
@children.each(&block)
end
each_node() { |c| ... }
click to toggle source
def each_node(&block)
@children.each do |c|
yield c
c.each(&block)
end
end
each_section(&block)
click to toggle source
def each_section(&block)
@children.each do |n|
n.yield_section(&block)
end
end
each_section_with_index() { |n, i| ... }
click to toggle source
def each_section_with_index
i = 0
each_section do |n|
yield n, i
i += 1
end
end
section_size()
click to toggle source
def section_size
cnt = 0
@children.each do |n|
n.yield_section { cnt += 1 }
end
cnt
end