Class: Sshster::ArgvParser

Inherits:
Object
  • Object
show all
Defined in:
lib/sshster/argv_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ ArgvParser

Returns a new instance of ArgvParser.



5
6
7
# File 'lib/sshster/argv_parser.rb', line 5

def initialize(argv)
  @argv = argv
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



3
4
5
# File 'lib/sshster/argv_parser.rb', line 3

def command
  @command
end

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/sshster/argv_parser.rb', line 3

def config
  @config
end

#helpObject (readonly)

Returns the value of attribute help.



3
4
5
# File 'lib/sshster/argv_parser.rb', line 3

def help
  @help
end

Instance Method Details

#parseObject



9
10
11
12
13
14
15
# File 'lib/sshster/argv_parser.rb', line 9

def parse
  options = parse_argv(@argv)
  @config = options['-c']
  @help = options['-h']
  @command = detect_command(options)
  self
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/sshster/argv_parser.rb', line 17

def valid?
  !@command.nil? && valid_commands.include?(@command)
end