Module: Savvy::Utility
- Defined in:
- lib/savvy/utility.rb
Class Method Summary collapse
-
.valid_env_var?(var) ⇒ Boolean
Validate that the provided var is a string that can be used as a name for environment variables.
-
.valid_env_vars?(vars) ⇒ Boolean
Validate that the provided value is a one-dimensional array of strings that may or may not exist in ‘ENV`.
- .valid_url?(url, scheme: nil) ⇒ Boolean
Class Method Details
.valid_env_var?(var) ⇒ Boolean
Validate that the provided var is a string that can be used as a name for environment variables.
22 23 24 |
# File 'lib/savvy/utility.rb', line 22 def valid_env_var?(var) var.kind_of?(String) && Dux.presentish?(var) end |
.valid_env_vars?(vars) ⇒ Boolean
Validate that the provided value is a one-dimensional array of strings that may or may not exist in ‘ENV`.
9 10 11 12 13 14 15 |
# File 'lib/savvy/utility.rb', line 9 def valid_env_vars?(vars) return false unless vars.kind_of?(Array) vars.all? do |var| valid_env_var? var end end |
.valid_url?(url, scheme: nil) ⇒ Boolean
26 27 28 29 30 31 32 33 34 |
# File 'lib/savvy/utility.rb', line 26 def valid_url?(url, scheme: nil) return false unless url.kind_of?(String) && Dux.presentish?(url) if scheme return false unless url.start_with?("#{scheme}://") end return true end |