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
rubocop:disable Metrics/MethodLength.
Constructor Details
#initialize(args) ⇒ ScriptOptions
Returns a new instance of ScriptOptions.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/hyrum/script_options.rb', line 13 def initialize(args) @options = { message: nil, validate: false, min_quality: 70, strict: false, show_scores: false } @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
rubocop:disable Metrics/MethodLength
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/hyrum/script_options.rb', line 25 def parse OptionParser.new do |parser| (parser) parser.parse!(@args) end set_dynamic_defaults rescue OptionParser::InvalidOption => e raise ScriptOptionsError, "Invalid option: #{e.}" rescue OptionParser::MissingArgument => e raise ScriptOptionsError, "Missing argument for option: #{e.}" rescue OptionParser::InvalidArgument => e raise ScriptOptionsError, "Invalid argument for option: #{e.}" end |