Class: Hyrum::ScriptOptions
- Inherits:
-
Object
- Object
- Hyrum::ScriptOptions
- Defined in:
- lib/hyrum/script_options.rb
Constant Summary collapse
- MANDATORY_OPTIONS =
%i[message].freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(args) ⇒ ScriptOptions
constructor
A new instance of ScriptOptions.
- #parse ⇒ Object
Constructor Details
#initialize(args) ⇒ ScriptOptions
Returns a new instance of ScriptOptions.
13 14 15 16 |
# File 'lib/hyrum/script_options.rb', line 13 def initialize(args) @options = {} @args = args end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/hyrum/script_options.rb', line 11 def @options end |
Instance Method Details
#parse ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hyrum/script_options.rb', line 18 def parse OptionParser.new do |parser| (parser) parser.parse!(@args) end set_dynamic_defaults rescue OptionParser::InvalidOption => e raise ScriptOptionsError.new("Invalid option: #{e.}") rescue OptionParser::MissingArgument => e raise ScriptOptionsError.new("Missing argument for option: #{e.}") rescue OptionParser::InvalidArgument => e raise ScriptOptionsError.new("Invalid argument for option: #{e.}") end |