Class: GithubCLI::Command::Arguments
- Inherits:
-
Object
- Object
- GithubCLI::Command::Arguments
- Defined in:
- lib/github_cli/command/arguments.rb
Overview
Makes it easy to parse required and options arguments.
Constant Summary collapse
- SEPARATOR =
'/'
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
Instance Method Summary collapse
-
#initialize(args) ⇒ Arguments
constructor
A new instance of Arguments.
-
#inspect ⇒ Object
Returns a concise string representation of Arguments instance.
-
#parse ⇒ Object
Returns seperated arguments.
Constructor Details
#initialize(args) ⇒ Arguments
Returns a new instance of Arguments.
12 13 14 |
# File 'lib/github_cli/command/arguments.rb', line 12 def initialize(args) @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
10 11 12 |
# File 'lib/github_cli/command/arguments.rb', line 10 def args @args end |
Instance Method Details
#inspect ⇒ Object
Returns a concise string representation of Arguments instance
31 32 33 |
# File 'lib/github_cli/command/arguments.rb', line 31 def inspect "#<#{self.class.inspect} @args=#{args.inspect}" end |
#parse ⇒ Object
Returns seperated arguments
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/github_cli/command/arguments.rb', line 17 def parse required, non_required = nil, nil if !args.empty? required = args non_required, required = required.split('/', 2) if required.index('/') else raise RequiredArgumentMissingError, "No value provided for required argument" end [non_required, required] end |