Module: Helpers

Included in:
Command::Base, Config
Defined in:
lib/core/helpers.rb

Class Method Summary collapse

Class Method Details

.normalize_command_name(name) ⇒ Object



19
20
21
# File 'lib/core/helpers.rb', line 19

def normalize_command_name(name)
  name.to_s.tr("_", "-")
end

.normalize_option_name(name) ⇒ Object



23
24
25
# File 'lib/core/helpers.rb', line 23

def normalize_option_name(name)
  "--#{name.to_s.tr('_', '-')}"
end

.random_four_digitsObject



15
16
17
# File 'lib/core/helpers.rb', line 15

def random_four_digits
  SecureRandom.random_number(1000..9999)
end

.strip_str_and_validate(str) ⇒ Object



8
9
10
11
12
13
# File 'lib/core/helpers.rb', line 8

def strip_str_and_validate(str)
  return str if str.nil?

  str = str.strip
  str.empty? ? nil : str
end