X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Ftype3x.rb;fp=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Ftype3x.rb;h=950171d38263a851ccf7a1673a2a9e77e224e418;hb=131e09855e065be940e104d9ab0f18940cc76257;hp=b17380e704069d26d5a5fd34391f937644cf0547;hpb=407d322498f4fde815abf381007fbecfe5c10b2b;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/type3x.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/type3x.rb index b17380e70..950171d38 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/type3x.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/type3x.rb @@ -1,28 +1,27 @@ # # type3x.rb # - module Puppet::Parser::Functions - newfunction(:type3x, :type => :rvalue, :doc => <<-EOS -DEPRECATED: This function will be removed when puppet 3 support is dropped; please migrate to the new parser's typing system. + newfunction(:type3x, :type => :rvalue, :doc => <<-DOC + DEPRECATED: This function will be removed when Puppet 3 support is dropped; please migrate to the new parser's typing system. -Returns the type when passed a value. Type can be one of: + Returns the type when passed a value. Type can be one of: -* string -* array -* hash -* float -* integer -* boolean - EOS - ) do |args| - raise(Puppet::ParseError, "type3x(): Wrong number of arguments given (#{args.size} for 1)") if args.size < 1 + * string + * array + * hash + * float + * integer + * boolean + DOC + ) do |args| + raise(Puppet::ParseError, "type3x(): Wrong number of arguments given (#{args.size} for 1)") unless args.size == 1 value = args[0] klass = value.class - if not [TrueClass, FalseClass, Array, Bignum, Fixnum, Float, Hash, String].include?(klass) + unless [TrueClass, FalseClass, Array, Bignum, Fixnum, Float, Hash, String].include?(klass) # rubocop:disable Lint/UnifiedInteger raise(Puppet::ParseError, 'type3x(): Unknown type') end @@ -30,16 +29,16 @@ Returns the type when passed a value. Type can be one of: # We note that Integer is the parent to Bignum and Fixnum ... result = case klass - when /^(?:Big|Fix)num$/ then 'integer' - when /^(?:True|False)Class$/ then 'boolean' - else klass - end - - if result == "String" then - if value == value.to_i.to_s then - result = "Integer" - elsif value == value.to_f.to_s then - result = "Float" + when %r{^(?:Big|Fix)num$} then 'integer' + when %r{^(?:True|False)Class$} then 'boolean' + else klass + end + + if result == 'String' + if value == value.to_i.to_s + result = 'Integer' + elsif value == value.to_f.to_s + result = 'Float' end end