Skip to content

Instantly share code, notes, and snippets.

@glarizza
Created December 6, 2013 00:20
Show Gist options
  • Save glarizza/7816585 to your computer and use it in GitHub Desktop.
Save glarizza/7816585 to your computer and use it in GitHub Desktop.
# <modulepath>/custom_functions/lib/puppet/parser/functions/longest.rb
Puppet::Parser::Functions.newfunction(:longest, :type => :rvalue, :doc => "Longest Function") do |args|
raise Puppet::Error, "#longest: accepts only one argument, you passed #{args.length}" if args.length != 1
raise Puppet::Error, "#longest: accepts a single Array, you passed: #{args[0].class}" if args[0].class != Array
@longest = ''
args[0].each do |item|
@longest = item if item.length > @longest.length
end
@lon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment