Class: CommandLine::OptionData
- Inherits:
-
Object
- Object
- CommandLine::OptionData
- Defined in:
- lib/commandline/optionparser/optiondata.rb
Overview
Data resulting from parsing a command line (Array) using a particular OptionParser object
Defined Under Namespace
Classes: OptionDataError, UnknownOptionError
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
#not_parsed ⇒ Object
readonly
Returns the value of attribute not_parsed.
-
#unknown_options ⇒ Object
readonly
Returns the value of attribute unknown_options.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(argv, opts, unknown_options, args, not_parsed, cmd) ⇒ OptionData
constructor
A new instance of OptionData.
Constructor Details
#initialize(argv, opts, unknown_options, args, not_parsed, cmd) ⇒ OptionData
Returns a new instance of OptionData.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/commandline/optionparser/optiondata.rb', line 27 def initialize(argv, opts, , args, not_parsed, cmd) @opts = {} opts.each { |k,v| @opts[k] = begin Marshal.load(Marshal.dump(v)) rescue v end } @unknown_options = Marshal.load(Marshal.dump()) @not_parsed = Marshal.load(Marshal.dump(not_parsed)) @argv = Marshal.load(Marshal.dump(argv)) @args = Marshal.load(Marshal.dump(args)) @cmd = Marshal.load(Marshal.dump(cmd)) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
22 23 24 |
# File 'lib/commandline/optionparser/optiondata.rb', line 22 def args @args end |
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
22 23 24 |
# File 'lib/commandline/optionparser/optiondata.rb', line 22 def argv @argv end |
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
22 23 24 |
# File 'lib/commandline/optionparser/optiondata.rb', line 22 def cmd @cmd end |
#not_parsed ⇒ Object (readonly)
Returns the value of attribute not_parsed.
22 23 24 |
# File 'lib/commandline/optionparser/optiondata.rb', line 22 def not_parsed @not_parsed end |
#unknown_options ⇒ Object (readonly)
Returns the value of attribute unknown_options.
22 23 24 |
# File 'lib/commandline/optionparser/optiondata.rb', line 22 def @unknown_options end |
Instance Method Details
#[](key) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/commandline/optionparser/optiondata.rb', line 44 def [](key) if @opts.has_key?(key) @opts[key] else raise(UnknownOptionError, "Unknown option '#{key}'.") end end |