Class: Card::Mod::Loader
- Inherits:
-
Object
show all
- Defined in:
- lib/card/mod/loader.rb,
lib/card/mod/loader/set_loader.rb,
lib/card/mod/loader/set_pattern_loader.rb
Overview
The mods are given by a Mod::Dirs object.
SetLoader can use three different strategies to load the set modules.
Defined Under Namespace
Classes: SetLoader, SetPatternLoader
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(load_strategy = :eval, mod_dirs = nil) ⇒ Loader
Returns a new instance of Loader.
20
21
22
23
24
|
# File 'lib/card/mod/loader.rb', line 20
def initialize load_strategy=:eval, mod_dirs=nil
mod_dirs ||= Mod.dirs
klass = load_strategy_class load_strategy
@load_strategy = klass.new mod_dirs, self
end
|
Class Attribute Details
.module_type ⇒ Object
Returns the value of attribute module_type.
39
40
41
|
# File 'lib/card/mod/loader.rb', line 39
def module_type
@module_type
end
|
Class Method Details
.load_chunks ⇒ Object
50
51
52
53
54
|
# File 'lib/card/mod/loader.rb', line 50
def load_chunks
Mod.dirs.each(:chunk) do |dir|
load_dir dir
end
end
|
.load_layouts(extension) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/card/mod/loader.rb', line 56
def load_layouts extension
hash = {}
Mod.dirs.each(:layout) do |dirname|
Dir.foreach(dirname) do |filename|
next if filename =~ /^\./ || filename !~ /\.#{extension}$/
layout_name = filename.gsub(/\.#{extension}$/, "")
hash[layout_name] = File.read File.join(dirname, filename)
end
end
hash
end
|
.module_class_template ⇒ Object
68
69
70
|
# File 'lib/card/mod/loader.rb', line 68
def module_class_template
const_get :Template
end
|
Instance Method Details
#load ⇒ Object
34
35
36
|
# File 'lib/card/mod/loader.rb', line 34
def load
@load_strategy.load_modules
end
|
#load_strategy_class(load_strategy) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/card/mod/loader.rb', line 26
def load_strategy_class load_strategy
case load_strategy
when :tmp_files then LoadStrategy::TmpFiles
when :binding_magic then LoadStrategy::BindingMagic
else LoadStrategy::Eval
end
end
|