Class: EnvSetup::Builder::Input

Inherits:
Base
  • Object
show all
Defined in:
lib/env_setup/builder/input.rb

Instance Attribute Summary

Attributes inherited from Base

#params, #template

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from EnvSetup::Builder::Base

Instance Method Details

#callObject



8
9
10
11
# File 'lib/env_setup/builder/input.rb', line 8

def call
  input_value = params[template['input']]
  valid?(input_value) ? input_value : invalid_error!(template)
end

#invalid_error!(input_name) ⇒ Object



13
14
15
# File 'lib/env_setup/builder/input.rb', line 13

def invalid_error!(input_name)
  raise EnvSetup::InvalidInput, "Required input #{input_name}"
end

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
# File 'lib/env_setup/builder/input.rb', line 17

def valid?(value)
  return false if value.nil?
  return false if value.is_a?(String) && value.strip.empty?

  true
end