Class: ShellOpts::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/shellopts/program.rb,
lib/shellopts/dump.rb

Overview

Option models an option as given by the user on the subcommand line. Compiled options (and possibly aggregated) options are stored in the Command#option_values array

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(grammar, name, argument) ⇒ Option

Returns a new instance of Option.



334
335
336
# File 'lib/shellopts/program.rb', line 334

def initialize(grammar, name, argument)
  @grammar, @name, @argument = grammar, name, argument
end

Instance Attribute Details

#argumentObject

Argument value or nil if not present. The value is a String, Integer, or Float depending the on the type of the option



326
327
328
# File 'lib/shellopts/program.rb', line 326

def argument
  @argument
end

#grammarObject (readonly)

Associated Grammar::Option object



319
320
321
# File 'lib/shellopts/program.rb', line 319

def grammar
  @grammar
end

#nameObject (readonly)

The actual name used on the shell command-line (String)



322
323
324
# File 'lib/shellopts/program.rb', line 322

def name
  @name
end

Instance Method Details

#dumpObject



153
154
155
# File 'lib/shellopts/dump.rb', line 153

def dump
  ::Kernel.puts [name, argument].compact.join(" ")
end