```ruby
module PuppetParse
  class Parser

    def initialize(file)
      # Read file and return parsed object
      pparser         = Puppet::Parser::Parser.new('production')
      if File.exists?(file)
        @object       = pparser.import(file)
      else
        'File does not exist'
      end
    end

    # Read parameters from parsed object, returns hash of parameters and default 
    # values
    def parameters
      result = (defined? @object.class.arguments) ? @object.class.arguments : {}
      result
    end

    # Read class from parsed object, returns string containing class
    def klass
      @object.last.name if (defined? @object.class.name)
    end

    # Read RDOC contents from parsed object, returns hash of paragraph headings
    # and the following paragraph contents 
    #(i.e. parameter and parameter documentation)
    def docs
      if !@object.last.doc.nil?
        rdoc            = RDoc::Markup.parse(@object.last.doc)
        docs            = {}

        rdoc.parts.each do |part|
          if part.respond_to?(:items)
            part.items.each do |item|
              key       = item.label.tr('^A-Za-z0-9_-', '')
              docs[key] = item.parts.first.parts
            end # do item
          end # endif
        end # do parm
  
        docs
      end # if nil?
    end # def docs

  end # class Parser
end # module PuppetParse
```

Return resource type object from Puppet::Parser::Parser.environment.known_resource_types instead of relying on result of import
user
```ruby
module PuppetParse
  class Parser

    def initialize(file)
      # Read file and return parsed object
      pparser         = Puppet::Parser::Parser.new('production')
      if File.exists?(file)
        @file = File.expand_path(file)
        pparser.import(@file)
        pparser.environment.known_resource_types.hostclasses.each do |x|
          @object = x.last if x.last.file == @file
        end
      else
        'File does not exist'
      end
    end

    # Read parameters from parsed object, returns hash of parameters and default 
    # values
    def parameters
      result = (defined? @object.class.arguments) ? @object.class.arguments : {}
      result
    end

    # Read class from parsed object, returns string containing class
    def klass
      @object.name if (defined? @object.class.name)
    end

    # Read RDOC contents from parsed object, returns hash of paragraph headings
    # and the following paragraph contents 
    #(i.e. parameter and parameter documentation)
    def docs
      if !@object.doc.nil?
        rdoc            = RDoc::Markup.parse(@object.doc)
        docs            = {}

        rdoc.parts.each do |part|
          if part.respond_to?(:items)
            part.items.each do |item|
              key       = item.label.tr('^A-Za-z0-9_-', '')
              docs[key] = item.parts.first.parts
            end # do item
          end # endif
        end # do parm
  
        docs
      end # if nil?
    end # def docs

  end # class Parser
end # module PuppetParse
```
assistant