Class: OptParseGen::Option

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

Overview

Represents a single option.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



6
7
8
# File 'lib/optparsegen.rb', line 6

def description
  @description
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



6
7
8
# File 'lib/optparsegen.rb', line 6

def name
  @name
end

#shortObject

Returns the value of attribute short

Returns:

  • (Object)

    the current value of short



6
7
8
# File 'lib/optparsegen.rb', line 6

def short
  @short
end

Instance Method Details

#opt_argsObject



15
16
17
18
19
20
21
# File 'lib/optparsegen.rb', line 15

def opt_args
  args = []
  args.push "--#{name}" if name
  args.push "-#{short}" if short
  args.push description if description
  args
end

#symbol_nameObject



11
12
13
# File 'lib/optparsegen.rb', line 11

def symbol_name
  ":#{underscored_name}"
end

#underscored_nameObject



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

def underscored_name
  name.sub('-', '_')
end