Class: RTFM::DescriptionSection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) {|_self| ... } ⇒ DescriptionSection

Returns a new instance of DescriptionSection.

Yields:

  • (_self)

Yield Parameters:



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

def initialize(*args)
  super
  self.options ||= []
  yield self if block_given?
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



2
3
4
# File 'lib/rtfm/sections/description.rb', line 2

def body
  @body
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



2
3
4
# File 'lib/rtfm/sections/description.rb', line 2

def options
  @options
end

Instance Method Details

#add_option(*args) ⇒ Object Also known as: option



9
10
11
12
13
14
# File 'lib/rtfm/sections/description.rb', line 9

def add_option(*args)
  if args.size == 1 && args.first.is_a?(Option)
  then self.options << args.first
  else self.options << Option.new(*args)
  end
end

#to_groffObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rtfm/sections/description.rb', line 17

def to_groff
  GroffString.groffify do |out|
    out.section "description"
    out << self.body
    if options.any?
      out.Bl "-tag", "-width", "\"mmmmmmmmmm\"", "-compact"
      options.each do |option|
        out << option.to_groff(:item)
      end
      out.El
      out.Pp
    end
  end
end