Class: Inch::CLI::Command::Options::Base Abstract
- Inherits:
-
Object
- Object
- Inch::CLI::Command::Options::Base
- Includes:
- TraceHelper, YardoptsHelper
- Defined in:
- lib/inch/cli/command/options/base.rb
Overview
Subclass and override #set_options
Abstract base class for CLI options. Provides some helper methods for the option parser.
Direct Known Subclasses
Constant Summary
Constants included from YardoptsHelper
YardoptsHelper::VALID_YARD_SWITCHES
Instance Attribute Summary
Attributes included from YardoptsHelper
Class Method Summary collapse
-
.attribute(name, default = nil) ⇒ void
Creates an attribute with an optional default value.
Instance Method Summary collapse
-
#parse(args) ⇒ void
Parses the given
args
“into” the current Options object. -
#set_options(opts) ⇒ void
Sets all options for the current Options object.
-
#verify ⇒ void
Verifies if the given options are valid.
Methods included from YardoptsHelper
#parse_yardopts_options, #yardopts_options
Methods included from TraceHelper
Class Method Details
.attribute(name, default = nil) ⇒ void
This method returns an undefined value.
Creates an attribute with an optional default value
29 30 31 32 33 34 35 36 |
# File 'lib/inch/cli/command/options/base.rb', line 29 def attribute(name, default = nil) define_method(name) do instance_variable_get("@#{name}") || default end define_method("#{name}=") do |value| instance_variable_set("@#{name}", value) end end |
Instance Method Details
#parse(args) ⇒ void
This method returns an undefined value.
Parses the given args
“into” the current Options object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/inch/cli/command/options/base.rb', line 47 def parse(args) opts = OptionParser.new opts. = usage descriptions.each do |text| opts.separator " " + text end (opts) (opts, args) end |
#set_options(opts) ⇒ void
Override to fill with individual options
This method returns an undefined value.
Sets all options for the current Options object
65 66 67 |
# File 'lib/inch/cli/command/options/base.rb', line 65 def (opts) (opts) end |
#verify ⇒ void
Override to fill with validations
This method returns an undefined value.
Verifies if the given options are valid
74 75 |
# File 'lib/inch/cli/command/options/base.rb', line 74 def verify end |