Class: Peregrin::Outliner::Section

Inherits:
Object
  • Object
show all
Defined in:
lib/peregrin/outliner.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Section) initialize(node = nil)

Returns 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?

Returns:

  • (Boolean)


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