module BCDice
Constants
- VERSION
Public Class Methods
all_game_systems()
click to toggle source
ゲームシステムのクラス一覧を返す ゲームシステム一覧がロードされていなければロードする
@return [Array<Class>]
# File lib/bcdice/loader.rb, line 18 def all_game_systems() require "bcdice/game_system" BCDice::GameSystem.constants.map { |class_name| BCDice::GameSystem.const_get(class_name) } end
dynamic_load(id)
click to toggle source
IDを指定して対象のソースコードを動的にロードし、そのクラスを取得する
@param id [String] ID @return [Class, nil]
# File lib/bcdice/loader.rb, line 27 def dynamic_load(id) class_name = id.tr(":.", "_") # 対象ディレクトリの外にあるファイルをロードされないように制約を設ける unless /\A[A-Z]\w*\z/.match?(class_name) return nil end require "bcdice/game_system/#{class_name}" return BCDice::GameSystem.const_get(class_name) rescue LoadError, NameError return nil end
game_system_class(id)
click to toggle source
IDを指定してゲームシステムのクラスを取得する ゲームシステム一覧がロードされていなければロードする
@param id [String] ID @return [Class, nil]
# File lib/bcdice/loader.rb, line 10 def game_system_class(id) all_game_systems.find { |game_system| game_system::ID == id } end