以下の内容はhttps://tbpgr.hatenablog.com/entry/20140505/1399288020より取得しました。


Ruby | Kernel | autoload?

概要

Kernel#autoload?(const_name)

詳細

const_name が Kernel.#autoload 設定されているか調べます。
autoload 設定されていないか、ロード済みなら nil を返します。

サンプルコード

loaded.rb

class Loaded
  def loaded
    "loaded"
  end
end

kernel_autoload.rb

# encoding: utf-8
require 'tbpgr_utils'

autoload :Loaded, './loaded'

bulk_puts_eval binding, <<-EOS
autoload? :Loaded
Loaded.new.loaded
autoload? :Loaded
EOS

__END__
下記はTbpgrUtils gemの機能
bulk_puts_eval

https://rubygems.org/gems/tbpgr_utils
https://github.com/tbpgr/tbpgr_utils
出力
autoload? :Loaded # => "./loaded"
Loaded.new.loaded # => "loaded"
autoload? :Loaded # => nil



以上の内容はhttps://tbpgr.hatenablog.com/entry/20140505/1399288020より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14