Class: RTFM::SeeAlsoSection

Inherits:
Object
  • Object
show all
Defined in:
lib/rtfm/sections/see_also.rb

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ SeeAlsoSection

Returns a new instance of SeeAlsoSection.

Yields:

  • (_self)

Yield Parameters:



3
4
5
6
# File 'lib/rtfm/sections/see_also.rb', line 3

def initialize
  @references = {}
  yield self if block_given?
end

Instance Method Details

#reference(title, section = 0) ⇒ Object



7
8
9
# File 'lib/rtfm/sections/see_also.rb', line 7

def reference(title, section = 0)
  (@references[section] ||= []) << title
end

#to_groffObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rtfm/sections/see_also.rb', line 10

def to_groff
  GroffString.groffify do |out|
    out.section "SEE ALSO"
    @references.keys.sort.each do |section|
      @references[section].sort.each do |title|
        if section == 0
        then out.reference title
        else out.reference title, section
        end
      end
    end
  end
end