Class: RTFM::Option

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descObject

Returns the value of attribute desc

Returns:

  • (Object)

    the current value of desc



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

def desc
  @desc
end

#optsObject

Returns the value of attribute opts

Returns:

  • (Object)

    the current value of opts



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

def opts
  @opts
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



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

def title
  @title
end

Instance Method Details

#argumentObject



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

def argument
  opts && (opts[:argument] || opts[:arg])
end

#to_groff(how) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rtfm/option.rb', line 11

def to_groff(how)
  GroffString.groffify do |out|
    args = [:Fl, self.title]
    
    if self.argument
      argument = self.argument.to_s
      if argument[0,1] == "<" && argument[-1,1] == ">"
        args << "Ao" << argument[1..-2] << "Ac"
      elsif argument[0,1] == "[" && argument[-1,1] == "]"
        args << "Oo" << argument[1..-2] << "Oc"
      else
        args << :Ar << argument
      end
    end
    
    case how
    when :option
      out.Op *args
    when :item
      out.Pp
      out.It *args
      out << self.desc
    end
  end
end