Class: Slimembedcop::Option
- Inherits:
-
Object
- Object
- Slimembedcop::Option
- Defined in:
- lib/slimembedcop/option.rb
Overview
Command line options.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#autocorrect ⇒ Object
readonly
Returns the value of attribute autocorrect.
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#default_config_path ⇒ Object
readonly
Returns the value of attribute default_config_path.
-
#default_path_patterns ⇒ Object
readonly
Returns the value of attribute default_path_patterns.
-
#forced_config_path ⇒ Object
readonly
Returns the value of attribute forced_config_path.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Option
constructor
A new instance of Option.
Constructor Details
#initialize(argv) ⇒ Option
Returns a new instance of Option.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/slimembedcop/option.rb', line 9 def initialize(argv) opt = OptionParser.new @version = false @autocorrect = false @forced_config_path = nil @color = nil @debug = false @default_config_path = File.('../default.yml', __dir__) @default_path_patterns = %w[**/*.slim].freeze opt. = 'Usage: slimembedcop [options] [file1, file2, ...]' opt.on('-v', '--version', 'Display version.') { @version = true } opt.on('-a', '--autocorrect', 'Autocorrect offenses.') { @autocorrect = true } opt.on('-c', '--config=', 'Specify configuration file.') { |path| @forced_config_path = path } opt.on('--[no-]color', 'Force color output on or off.') { |value| @color = value } opt.on('-d', '--debug', 'Display debug info.') { |value| @debug = value } @args = opt.parse(argv) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
6 7 8 |
# File 'lib/slimembedcop/option.rb', line 6 def args @args end |
#autocorrect ⇒ Object (readonly)
Returns the value of attribute autocorrect.
6 7 8 |
# File 'lib/slimembedcop/option.rb', line 6 def autocorrect @autocorrect end |
#color ⇒ Object (readonly)
Returns the value of attribute color.
6 7 8 |
# File 'lib/slimembedcop/option.rb', line 6 def color @color end |
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
6 7 8 |
# File 'lib/slimembedcop/option.rb', line 6 def debug @debug end |
#default_config_path ⇒ Object (readonly)
Returns the value of attribute default_config_path.
6 7 8 |
# File 'lib/slimembedcop/option.rb', line 6 def default_config_path @default_config_path end |
#default_path_patterns ⇒ Object (readonly)
Returns the value of attribute default_path_patterns.
6 7 8 |
# File 'lib/slimembedcop/option.rb', line 6 def default_path_patterns @default_path_patterns end |
#forced_config_path ⇒ Object (readonly)
Returns the value of attribute forced_config_path.
6 7 8 |
# File 'lib/slimembedcop/option.rb', line 6 def forced_config_path @forced_config_path end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
6 7 8 |
# File 'lib/slimembedcop/option.rb', line 6 def version @version end |