Sha256: bc16aae3f699f93fa95840c2b01dc8055a9de3d5beba86242e6841c205ac5f6a

Contents?: true

Size: 965 Bytes

Versions: 32

Compression:

Stored size: 965 Bytes

Contents

# frozen_string_literal: true
##
# A file loaded by \#require

class RDoc::Require < RDoc::CodeObject

  ##
  # Name of the required file

  attr_accessor :name

  ##
  # Creates a new Require that loads +name+ with +comment+

  def initialize(name, comment)
    super()
    @name = name.gsub(/'|"/, "") #'
    @top_level = nil
    self.comment = comment
  end

  def inspect # :nodoc:
    "#<%s:0x%x require '%s' in %s>" % [
      self.class,
      object_id,
      @name,
      parent_file_name,
    ]
  end

  def to_s # :nodoc:
    "require #{name} in: #{parent}"
  end

  ##
  # The RDoc::TopLevel corresponding to this require, or +nil+ if not found.

  def top_level
    @top_level ||= begin
      tl = RDoc::TopLevel.all_files_hash[name + '.rb']

      if tl.nil? and RDoc::TopLevel.all_files.first.full_name =~ %r(^lib/) then
        # second chance
        tl = RDoc::TopLevel.all_files_hash['lib/' + name + '.rb']
      end

      tl
    end
  end

end

Version data entries

32 entries across 32 versions & 4 rubygems

Version Path
ric-0.12.2 vendor/bundle/ruby/2.5.0/gems/rdoc-6.1.1/lib/rdoc/require.rb
rdoc-6.1.1 lib/rdoc/require.rb
rdoc-6.1.0 lib/rdoc/require.rb
rdoc-6.1.0.beta3 lib/rdoc/require.rb
rdoc-6.1.0.beta2 lib/rdoc/require.rb
rdoc-6.1.0.beta1 lib/rdoc/require.rb
rdoc-6.0.4 lib/rdoc/require.rb
rdoc-6.0.3 lib/rdoc/require.rb
rdoc-6.0.2 lib/rdoc/require.rb
rdoc-6.0.1 lib/rdoc/require.rb
rdoc-6.0.0 lib/rdoc/require.rb
rdoc-6.0.0.beta4 lib/rdoc/require.rb