Module: EasyAppHelper::Scripts::ParametersHelper

Defined in:
lib/easy_app_helper/scripts/parameters_helper.rb

Instance Method Summary collapse

Instance Method Details

#normalize_param(param) ⇒ String or Symbol

Allows to specify a Ruby Symbol as a string. Supposed to be used to pass symbols from the command line.

Parameters:

  • param (String)

    A string coming normally from the command line.

Returns:

  • (String or Symbol)

    if param starts with a colon, then it the returns a symbol, ie: ‘:foo’ returns :foo (the Symbol) Else it will return the param itself. ‘bar’ returns ‘bar’ (the String)



12
13
14
15
16
17
# File 'lib/easy_app_helper/scripts/parameters_helper.rb', line 12

def normalize_param(param)
  param.match(/^:(?<param>.+)$/) do |md|
    param = md['param'].to_sym
  end
  param
end