value = arguments[0]
klass = value.class
- if not [Array, String].include?(klass)
- raise(Puppet::ParseError, 'chomp(): Requires either an ' +
+ unless [Array, String].include?(klass)
+ raise(Puppet::ParseError, 'chomp(): Requires either ' +
'array or string to work with')
end
if value.is_a?(Array)
+ # Numbers in Puppet are often string-encoded ...
result = value.collect { |i| i.is_a?(String) ? i.chomp : i }
else
result = value.chomp
value = arguments[0]
klass = value.class
- if not [Array, String].include?(klass)
+ unless [Array, String].include?(klass)
raise(Puppet::ParseError, 'chop(): Requires either an ' +
'array or string to work with')
end
if value.is_a?(Array)
+ # Numbers in Puppet are often string-encoded ...
result = value.collect { |i| i.is_a?(String) ? i.chop : i }
else
result = value.chop
array = arguments[0]
- if not array.is_a?(Array)
- raise(Puppet::ParseError, 'count(): Requires an array to work with')
+ unless array.is_a?(Array)
+ raise(Puppet::ParseError, 'count(): Requires array to work with')
end
item = arguments[1] if arguments[1]
fact = arguments[0]
- if not fact.is_a?(String)
+ unless fact.is_a?(String)
raise(Puppet::ParseError, 'fact(): Requires fact name to be a string')
end
array = arguments[0]
- if not array.is_a?(Array)
- raise(Puppet::ParseError, 'join(): Requires an array to work with')
+ unless array.is_a?(Array)
+ raise(Puppet::ParseError, 'join(): Requires array to work with')
end
suffix = arguments[1] if arguments[1]
array = arguments[0]
- if not array.is_a?(Array)
- raise(Puppet::ParseError, 'join_with_prefix(): Requires an ' +
+ unless array.is_a?(Array)
+ raise(Puppet::ParseError, 'join_with_prefix(): Requires ' +
'array to work with')
end
hash = arguments[0]
- if not hash.is_a?(Hash)
- raise(Puppet::ParseError, 'keys(): Requires a hash to work with')
+ unless hash.is_a?(Hash)
+ raise(Puppet::ParseError, 'keys(): Requires hash to work with')
end
result = hash.keys
value = arguments[0]
klass = value.class
- if not [Array, String].include?(klass)
- raise(Puppet::ParseError, 'lstrip(): Requires either an ' +
+ unless [Array, String].include?(klass)
+ raise(Puppet::ParseError, 'lstrip(): Requires either ' +
'array or string to work with')
end
array = arguments[0]
- if not array.is_a?(Array)
- raise(Puppet::ParseError, 'prefix(): Requires an array to work with')
+ unless array.is_a?(Array)
+ raise(Puppet::ParseError, 'prefix(): Requires array to work with')
end
prefix = arguments[1] if arguments[1]
value = arguments[0]
klass = value.class
- if not [Array, String].include?(klass)
- raise(Puppet::ParseError, 'reverse(): Requires either an ' +
+ unless [Array, String].include?(klass)
+ raise(Puppet::ParseError, 'reverse(): Requires either ' +
'array or string to work with')
end
value = arguments[0]
klass = value.class
- if not [Array, String].include?(klass)
- raise(Puppet::ParseError, 'rstrip(): Requires either an ' +
+ unless [Array, String].include?(klass)
+ raise(Puppet::ParseError, 'rstrip(): Requires either ' +
'array or string to work with')
end
string = arguments[0]
- if not string.is_a?(String)
- raise(Puppet::ParseError, 'str2bool(): Requires either a ' +
+ unless string.is_a?(String)
+ raise(Puppet::ParseError, 'str2bool(): Requires either ' +
'string to work with')
end
+ # We consider all the yes, no, y, n and so on too ...
result = case string
#
# This is how undef looks like in Puppet ...
hash = arguments[0]
- if not hash.is_a?(Hash)
- raise(Puppet::ParseError, 'values(): Requires a hash to work with')
+ unless hash.is_a?(Hash)
+ raise(Puppet::ParseError, 'values(): Requires hash to work with')
end
result = hash.values
array = arguments.shift
- if not array.is_a?(Array)
- raise(Puppet::ParseError, 'values_at(): Requires an array ' +
- 'to work with')
+ unless array.is_a?(Array)
+ raise(Puppet::ParseError, 'values_at(): Requires array to work with')
end
indices = *arguments # Get them all ... Pokemon ...