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.
179
180
181
182
|
# File 'ext/cumo/narray/gen/erbpp2.rb', line 179
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
199
200
201
|
# File 'ext/cumo/narray/gen/erbpp2.rb', line 199
def _mod_var
@opts[:module_var]
end
|
#cumo_id_list ⇒ Object
183
184
185
|
# File 'ext/cumo/narray/gen/erbpp2.rb', line 183
def cumo_id_list
@cumo_id_list ||= []
end
|
#def_id(name, var = nil) ⇒ Object
186
187
188
189
|
# File 'ext/cumo/narray/gen/erbpp2.rb', line 186
def def_id(name, var=nil)
var = name.gsub(/\?/, "_p").gsub(/\!/, "_bang") if var.nil?
cumo_id_list << [name, var]
end
|
#init_def ⇒ Object
190
191
192
|
# File 'ext/cumo/narray/gen/erbpp2.rb', line 190
def init_def
load_erb(init_erb).result(binding)
end
|
#init_erb ⇒ Object
193
194
195
|
# File 'ext/cumo/narray/gen/erbpp2.rb', line 193
def init_erb
@opts[:init_erb] || "init_module"
end
|
#method_code ⇒ Object
196
197
198
|
# File 'ext/cumo/narray/gen/erbpp2.rb', line 196
def method_code
@children.map { |c| c.result }.join("\n")
end
|