Sha256: 7129086afb68523a1165139f3a5d63463ff4dd8c3c0ba40f5575c2e6e690550b
Contents?: true
Size: 2 KB
Versions: 19
Compression:
Stored size: 2 KB
Contents
# frozen_string_literal: true KManager.action :array_commands do action do CmdletDirector .init(k_builder, category: :array) .cmdlet do name :join description 'join an array of values with separator as a string' result 'new String formed by joining the array elements with seperator' parameter :values, 'array of values to join', param_type: 'String|Int' parameter :separator, 'separator between values, defaults to comma', default: "','" ruby <<-RUBY return false if values.nil? || values.length == 0 values = values.reject(&:blank?) return '' if values.length.zero? values.join(separator) RUBY end .cmdlet do name :join_pre description 'join an array of values with separator as a string and using the separator at the beginning of string' parameter :values, 'array of values to join', param_type: 'String|Int' parameter :separator, 'separator between values, defaults to comma', default: "','" ruby <<-'RUBY' return '' if values.nil? || !values.is_a?(::Array) values = values.reject(&:blank?) return '' if values.length.zero? "#{separator}#{values.join(separator)}" RUBY end .cmdlet do name :join_post description 'join an array of values with separator as a string and using the separator at the end of string' parameter :values, 'array of values to join', param_type: 'String|Int' parameter :separator, 'separator between values, defaults to comma', default: "','" ruby <<-'RUBY' return '' if values.nil? || !values.is_a?(::Array) values = values.reject(&:blank?) return '' if values.length.zero? "#{values.join(separator)}#{separator}" RUBY end .generate # .debug end end
Version data entries
19 entries across 19 versions & 1 rubygems