Class: Peregrin::Outliner::Section
- Inherits:
-
Object
- Object
- Peregrin::Outliner::Section
- Defined in:
- lib/peregrin/outliner.rb
Instance Attribute Summary (collapse)
-
- (Object) container
Returns the value of attribute container.
-
- (Object) heading
Returns the value of attribute heading.
-
- (Object) node
Returns the value of attribute node.
-
- (Object) sections
Returns the value of attribute sections.
Instance Method Summary (collapse)
- - (Object) append(subsection)
- - (Boolean) empty?
- - (Object) heading_rank
- - (Object) heading_text
-
- (Section) initialize(node = nil)
constructor
A new instance of Section.
Constructor Details
- (Section) initialize(node = nil)
A new instance of Section
57 58 59 60 |
# File 'lib/peregrin/outliner.rb', line 57 def initialize(node = nil) self.node = node self.sections = [] end |
Instance Attribute Details
- (Object) container
Returns the value of attribute container
54 55 56 |
# File 'lib/peregrin/outliner.rb', line 54 def container @container end |
- (Object) heading
Returns the value of attribute heading
54 55 56 |
# File 'lib/peregrin/outliner.rb', line 54 def heading @heading end |
- (Object) node
Returns the value of attribute node
54 55 56 |
# File 'lib/peregrin/outliner.rb', line 54 def node @node end |
- (Object) sections
Returns the value of attribute sections
54 55 56 |
# File 'lib/peregrin/outliner.rb', line 54 def sections @sections end |
Instance Method Details
- (Object) append(subsection)
63 64 65 66 |
# File 'lib/peregrin/outliner.rb', line 63 def append(subsection) subsection.container = self sections.push(subsection) end |
- (Boolean) empty?
69 70 71 |
# File 'lib/peregrin/outliner.rb', line 69 def empty? heading_text.nil? && sections.all? { |sxn| sxn.empty? } end |
- (Object) heading_rank
83 84 85 86 |
# File 'lib/peregrin/outliner.rb', line 83 def heading_rank # FIXME: some doubt as to whether 1 is the sensible default Utils.heading?(heading) ? Utils.heading_rank(heading) : 1 end |
- (Object) heading_text
74 75 76 77 78 79 80 |
# File 'lib/peregrin/outliner.rb', line 74 def heading_text return nil unless Utils.heading?(heading) h = heading h = h.at_css("h#{Utils.heading_rank(h)}") if Utils.named?(h, 'HGROUP') return nil unless h && !h.content.strip.empty? h.content.strip end |