Puppet Function: :'stdlib::end_with'

Defined in:
modules/stdlib/lib/puppet/functions/stdlib/end_with.rb
Function type:
Ruby 4.x API

Overview

:'stdlib::end_with'(String[1] $test_string, Variant[String[1],Array[String[1], 1]] $suffixes)Boolean

Examples:

'foobar'.stdlib::end_with('bar') => true
'foobar'.stdlib::end_with('foo') => false
'foobar'.stdlib::end_with(['foo', 'baz']) => false

Parameters:

  • test_string (String[1])

    The string to check

  • suffixes (Variant[String[1],Array[String[1], 1]])

    The suffixes to check

Returns:

  • (Boolean)

    True or False



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'modules/stdlib/lib/puppet/functions/stdlib/end_with.rb', line 4

Puppet::Functions.create_function(:'stdlib::end_with') do
  # @param test_string The string to check
  # @param suffixes The suffixes to check
  # @example
  #    'foobar'.stdlib::end_with('bar') => true
  #    'foobar'.stdlib::end_with('foo') => false
  #    'foobar'.stdlib::end_with(['foo', 'baz']) => false
  # @return [Boolean] True or False
  dispatch :end_with do
    param 'String[1]', :test_string
    param 'Variant[String[1],Array[String[1], 1]]', :suffixes
    return_type 'Boolean'
  end

  def end_with(test_string, suffixes)
    test_string.end_with?(*suffixes)
  end
end