Class: YARD::Amp::OptionObject

Inherits:
CodeObjects::Base
  • Object
show all
Defined in:
lib/yard-amp/option.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace, name, description, opts = {}, *args) ⇒ OptionObject

Returns a new instance of OptionObject.



4
5
6
7
8
# File 'lib/yard-amp/option.rb', line 4

def initialize(namespace, name, description, opts = {}, *args)
  super
  self.description, self.options = description, opts
  opts["type"] ||= "flag"
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/yard-amp/option.rb', line 3

def description
  @description
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/yard-amp/option.rb', line 3

def options
  @options
end

Instance Method Details

#signatureObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/yard-amp/option.rb', line 10

def signature
  "--#{self.name}" +
    (options["short"] && options["short"] != "none" ? ", -#{options["short"]}" : "") +
    case options["type"]
    when "flag"; ""
    when "int"; " <i>"
    when "ints"; " <i+>"
    when "string"; " <s>"
    when "strings"; " <s+>"
    when "float"; " <f>"
    when "floats"; " <f+>"
    when "io"; " <filename/uri>"
    when "ios"; " <filename/uri+>"
    end.to_s
end