HEX
Server: Apache
System: Linux sg241.singhost.net 2.6.32-896.16.1.lve1.4.51.el6.x86_64 #1 SMP Wed Jan 17 13:19:23 EST 2018 x86_64
User: honghock (909)
PHP: 8.0.30
Disabled: passthru,system,shell_exec,show_source,exec,popen,proc_open
Upload Files
File: //usr/lib/ruby/site_ruby/1.8/puppet/pops/types/enumeration.rb
# The Enumeration class provides default Enumerable::Enumerator creation for Puppet Programming Language
# runtime objects that supports the concept of enumeration.
#
class Puppet::Pops::Types::Enumeration
  # Produces an Enumerable::Enumerator for Array, Hash, Integer, Integer Range, and String.
  #
  def self.enumerator(o)
    @@singleton ||= new
    @@singleton.enumerator(o)
  end

  # Produces an Enumerator for Array, Hash, Integer, Integer Range, and String.
  #
  def enumerator(o)
    case o
    when String
      x = o.chars
      # Ruby 1.8.7 returns Enumerable::Enumerator, Ruby 1.8.9 Enumerator, and 2.0.0 an Array
      x.is_a?(Array) ? x.each : x
    when Integer
      o.times
    when Array
      o.each
    when Hash
      o.each
    when Puppet::Pops::Types::PIntegerType
      # Not enumerable if representing an infinite range
      return nil if o.to.nil? || o.from.nil?
      o.each
    else
      nil
    end
  end
end