Class: DefModule
Instance Attribute Summary
Attributes inherited from ErbPP
#children, #parent
Instance Method Summary
collapse
Methods included from DeclMethod
#def_alias, #def_alloc_func, #def_const, #def_method, #def_module_function, #def_singleton_method, #undef_alloc_func, #undef_method, #undef_singleton_method
Methods inherited from ErbPP
#add_child, #description, #find, #find_tmpl, #get, #load_erb, #method_missing, #method_missing_alias, #result, #run, #set, #write
Constructor Details
#initialize(parent, **opts, &block) ⇒ DefModule
Returns a new instance of DefModule.
177
178
179
180
|
# File 'ext/cumo/narray/gen/erbpp2.rb', line 177
def initialize(parent, **opts, &block)
eb = opts[:erb_base] || 'module'
super(parent, erb_base:eb, **opts, &block)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class ErbPP
Instance Method Details
#_mod_var ⇒ Object
197
198
199
|
# File 'ext/cumo/narray/gen/erbpp2.rb', line 197
def _mod_var
@opts[:module_var]
end
|
#cumo_id_list ⇒ Object
181
182
183
|
# File 'ext/cumo/narray/gen/erbpp2.rb', line 181
def cumo_id_list
@cumo_id_list ||= []
end
|
#def_id(name, var = nil) ⇒ Object
184
185
186
187
|
# File 'ext/cumo/narray/gen/erbpp2.rb', line 184
def def_id(name,var=nil)
var = name.gsub(/\?/,"_p").gsub(/\!/,"_bang") if var.nil?
cumo_id_list << [name,var]
end
|
#init_def ⇒ Object
188
189
190
|
# File 'ext/cumo/narray/gen/erbpp2.rb', line 188
def init_def
load_erb(init_erb).result(binding)
end
|
#init_erb ⇒ Object
191
192
193
|
# File 'ext/cumo/narray/gen/erbpp2.rb', line 191
def init_erb
@opts[:init_erb] || "init_module"
end
|
#method_code ⇒ Object
194
195
196
|
# File 'ext/cumo/narray/gen/erbpp2.rb', line 194
def method_code
@children.map{|c| c.result}.join("\n")
end
|