Sha256: e2e19aa65ae0720f4c1a343cda49bf034838a5ed4b201c187d8f6db0cb8d50e2

Contents?: true

Size: 970 Bytes

Versions: 23

Compression:

Stored size: 970 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module Utils
    module Array
      class Rjust < Support::Command
        ##
        # @!attribute [r] array
        #   @return [Array]
        #
        attr_reader :array

        ##
        # @!attribute [r] size
        #   @return [Integer]
        #
        attr_reader :size

        ##
        # @!attribute [r] pad
        #   @return [Object] Can be any type.
        #
        attr_reader :pad

        ##
        # @param array [Array]
        # @param size [Integer]
        # @param pad [Object] Can be any type.
        # @return [void]
        #
        def initialize(array, size, pad = nil)
          @array = array
          @size = size
          @pad = pad
        end

        ##
        # @return [Array]
        #
        def call
          return array if size <= array.size

          count = size - array.size

          array + [pad] * count
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
convenient_service-0.19.1 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.19.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.18.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.17.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.16.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.15.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.14.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.13.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.12.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.11.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.10.1 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.10.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.9.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.8.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.7.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.6.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.5.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.4.0 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.3.1 lib/convenient_service/utils/array/rjust.rb
convenient_service-0.3.0 lib/convenient_service/utils/array/rjust.rb