Class: Ripe::CLI::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/ripe/cli/helper.rb

Overview

This class defines helper methods for Ripe::CLI.

See Also:

Class Method Summary collapse

Class Method Details

.parse_cli_opts(options) ⇒ Hash

Parses a string representing a hash in the format of a=1,b=2,c=3 into a hash in the format of {a: 1, b: 2, c: 3}.

Parameters:

  • options (String)

    a hash in the format of a=1,b=2,c=3

Returns:

  • (Hash)

    a hash in the format of {a: 1, b: 2, c: 3}



19
20
21
22
23
24
25
# File 'lib/ripe/cli/helper.rb', line 19

def self.parse_cli_opts(options)
  params = options.split(/,/).map do |pair|
    key, value = pair.split(/=/)
    { key.to_sym => value }
  end
  params.inject(&:merge) || {}
end