Class: Card::Mod::Loader::SetLoader::Template
Instance Method Summary
collapse
#build, #simple_load?, #to_s
Constructor Details
#initialize(modules, content_path) ⇒ Template
29
30
31
32
|
# File 'lib/card/mod/loader/set_loader.rb', line 29
def initialize modules, content_path
super
@modules.pop if helper_module?
end
|
Instance Method Details
#helper_module? ⇒ Boolean
45
46
47
48
49
50
51
|
# File 'lib/card/mod/loader/set_loader.rb', line 45
def helper_module?
if @is_helper_module.nil?
@is_helper_module = @content =~ /\A#!\s?not? set module/
else
@is_helper_module
end
end
|
#offset ⇒ Object
correct line number for error messages
54
55
56
57
58
59
|
# File 'lib/card/mod/loader/set_loader.rb', line 54
def offset
helper_module? ? -4 : -5
end
|
#to_const ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/card/mod/loader/set_loader.rb', line 34
def to_const
return Object if simple_load?
pattern_klass = Card::Set.const_get_or_set(@pattern.camelize) { Class.new }
@modules.inject(pattern_klass) do |const, name_part|
const.const_get_or_set name_part do
Module.new
end
end
end
|