module StringUtils
Module containing string utilities for cli-proton-ruby clients
Public Class Methods
sha1_hash(value)
click to toggle source
# File lib/utils/string_utils.rb, line 75 def self.sha1_hash(value) Digest::SHA1.hexdigest value.to_s end
str_is_bool?(value)
click to toggle source
Function to check if string variable is convertible to client bool value
Returns¶ ↑
true if string variable is convertible to client bool value, false otherwise
# File lib/utils/string_utils.rb, line 43 def self.str_is_bool?(value) begin str_to_bool value rescue ArgumentError return false end return true end
str_is_float?(value)
click to toggle source
str_is_int?(value)
click to toggle source
str_to_bool(value)
click to toggle source
Function to convert string variable to client bool value (yes/no|True/False|true/false)
Parameters¶ ↑
- value
-
string variable to convert
Returns¶ ↑
bool value of the variable
Raises¶ ↑
ArgumentError for invalid argument
# File lib/utils/string_utils.rb, line 61 def self.str_to_bool(value) # If positive value if ["yes", "True", "true"].include?(value) # Return true return true # If negative value elsif ["no", "False", "false"].include?(value) # Return false return false end # If value is not convertible, raise ArgumentError raise ArgumentError, "invalid value for Boolean(): \"#{value}\"" end