Class: RTFM::SeeAlsoSection
- Inherits:
-
Object
- Object
- RTFM::SeeAlsoSection
- Defined in:
- lib/rtfm/sections/see_also.rb
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ SeeAlsoSection
constructor
A new instance of SeeAlsoSection.
- #reference(title, section = 0) ⇒ Object
- #to_groff ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ SeeAlsoSection
Returns a new instance of SeeAlsoSection.
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_groff ⇒ Object
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 |