Sha256: ea5988e855af6988be075c9ec2896a31c972d078b068b9392185e9bc26220471

Contents?: true

Size: 707 Bytes

Versions: 30

Compression:

Stored size: 707 Bytes

Contents

# frozen_string_literal: true

module Cmdlet
  # Array handling routines, eg. join, join_prefix, join_post
  module Array
    # JoinPost: join an array of values with separator as a string and using the separator at the end of string
    class JoinPost < Cmdlet::BaseCmdlet
      #
      # @param [String|Int] values - array of values to join
      # @param [String] separator - separator between values, defaults to comma
      # @return [String]
      def call(values, separator = ',')
        return '' if values.nil? || !values.is_a?(::Array)

        values = values.reject(&:blank?)
        return '' if values.length.zero?

        "#{values.join(separator)}#{separator}"
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
cmdlet-0.14.0 lib/cmdlet/array/join_post.rb
cmdlet-0.13.2 lib/cmdlet/array/join_post.rb
cmdlet-0.13.1 lib/cmdlet/array/join_post.rb
cmdlet-0.13.0 lib/cmdlet/array/join_post.rb
cmdlet-0.12.5 lib/cmdlet/array/join_post.rb
cmdlet-0.12.4 lib/cmdlet/array/join_post.rb
cmdlet-0.12.3 lib/cmdlet/array/join_post.rb
cmdlet-0.12.2 lib/cmdlet/array/join_post.rb
cmdlet-0.12.1 lib/cmdlet/array/join_post.rb
cmdlet-0.12.0 lib/cmdlet/array/join_post.rb
cmdlet-0.11.0 lib/cmdlet/array/join_post.rb
cmdlet-0.10.1 lib/cmdlet/array/join_post.rb
cmdlet-0.10.0 lib/cmdlet/array/join_post.rb
cmdlet-0.9.2 lib/cmdlet/array/join_post.rb
cmdlet-0.9.1 lib/cmdlet/array/join_post.rb
cmdlet-0.9.0 lib/cmdlet/array/join_post.rb
cmdlet-0.8.0 lib/cmdlet/array/join_post.rb
cmdlet-0.7.1 lib/cmdlet/array/join_post.rb
cmdlet-0.7.0 lib/cmdlet/array/join_post.rb
cmdlet-0.6.2 lib/cmdlet/array/join_post.rb