class CLIArg
Attributes
args[R]
identifiers[R]
options[R]
validator[RW]
Public Class Methods
new(args)
click to toggle source
# File lib/pry-globs/cli_arg.rb, line 5 def initialize(args) @args = args @options = fetch_options @identifiers = fetch_identifiers @validator = CLIArgValidator.new(self) end
Public Instance Methods
empty?()
click to toggle source
# File lib/pry-globs/cli_arg.rb, line 28 def empty? args.empty? end
invalid?()
click to toggle source
# File lib/pry-globs/cli_arg.rb, line 16 def invalid? validator.args_invalid? end
invalid_msg()
click to toggle source
# File lib/pry-globs/cli_arg.rb, line 12 def invalid_msg validator.args_invalid_msg end
option_present?()
click to toggle source
# File lib/pry-globs/cli_arg.rb, line 24 def option_present? !valid[:option].empty? end
valid()
click to toggle source
# File lib/pry-globs/cli_arg.rb, line 20 def valid @valid ||= { option: option, identifier_token: identifier } end
Private Instance Methods
fetch_identifiers()
click to toggle source
# File lib/pry-globs/cli_arg.rb, line 40 def fetch_identifiers args.select { |arg| arg[0] != '-' } end
fetch_options()
click to toggle source
# File lib/pry-globs/cli_arg.rb, line 36 def fetch_options args.select { |arg| arg[0] == '-' } end
identifier()
click to toggle source
# File lib/pry-globs/cli_arg.rb, line 48 def identifier identifiers.first end
option()
click to toggle source
# File lib/pry-globs/cli_arg.rb, line 44 def option options.first || '' end