Sha256: a77018a6bb8bd65dba936089eb494aa8bab0c89bf2fc288658592791cbc310f2

Contents?: true

Size: 890 Bytes

Versions: 13

Compression:

Stored size: 890 Bytes

Contents

# frozen_string_literal: true

module Cmdlet
  # String manipulation
  module Str
    # Padl: take the value and give it padding on the left hand side
    class Padl < Cmdlet::BaseCmdlet
      #
      # @param [String|Symbol|Int] value - value to apply padding to
      # @param [Int] count - how much padding to apply. defaults to configuration.padl_count
      # @param [String] char - character to pad with. defaults to configuration.padl_char
      # @return [String] the value padded on LHS with [char (default &#x27; &#x27;)] and [count (default 30)]
      def call(value, count = nil, char = nil)
        value = '' if value.nil?
        count = KConfig.configuration.cmdlet.padl_count if count.nil?
        count = count.to_i if count.is_a?(String)
        char = KConfig.configuration.cmdlet.padl_char if char.nil?
        value.to_s.rjust(count, char)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
cmdlet-0.14.0 lib/cmdlet/str/padl.rb
cmdlet-0.13.2 lib/cmdlet/str/padl.rb
cmdlet-0.13.1 lib/cmdlet/str/padl.rb
cmdlet-0.13.0 lib/cmdlet/str/padl.rb
cmdlet-0.12.5 lib/cmdlet/str/padl.rb
cmdlet-0.12.4 lib/cmdlet/str/padl.rb
cmdlet-0.12.3 lib/cmdlet/str/padl.rb
cmdlet-0.12.2 lib/cmdlet/str/padl.rb
cmdlet-0.12.1 lib/cmdlet/str/padl.rb
cmdlet-0.12.0 lib/cmdlet/str/padl.rb
cmdlet-0.11.0 lib/cmdlet/str/padl.rb
cmdlet-0.10.1 lib/cmdlet/str/padl.rb
cmdlet-0.10.0 lib/cmdlet/str/padl.rb