Class: DefSubclassNew
- Defined in:
- ext/numo/gsl/gen/erbpp_gsl.rb
Instance Attribute Summary
Attributes inherited from ErbPP
Instance Method Summary collapse
- #c_func(narg = nil) ⇒ Object
- #init_def ⇒ Object
-
#initialize(parent, tmpl, var, subtp = nil, **h) ⇒ DefSubclassNew
constructor
A new instance of DefSubclassNew.
Methods inherited from DefMethod
#c_iter, #c_name, #define_method_args, #id_op, #op_map, #singleton
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, tmpl, var, subtp = nil, **h) ⇒ DefSubclassNew
Returns a new instance of DefSubclassNew.
75 76 77 78 79 80 81 82 83 84 |
# File 'ext/numo/gsl/gen/erbpp_gsl.rb', line 75 def initialize(parent,tmpl,var,subtp=nil,**h) super(parent, tmpl, name:"new", **h) if !subtp subtp = var.sub(/gsl_#{parent.name}_/,"") end set subtype_var: var set subtype_name: subtp set subtype_class: subtp.split('_').map{|x| x.capitalize}.join("") set c_superclass_new: "#{parent.name}_s_new" end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ErbPP
Instance Method Details
#c_func(narg = nil) ⇒ Object
86 87 88 89 |
# File 'ext/numo/gsl/gen/erbpp_gsl.rb', line 86 def c_func(narg=nil) super(narg) "#{@parent.name}_#{get(:subtype_name)}_s_new" end |
#init_def ⇒ Object
91 92 93 94 95 96 |
# File 'ext/numo/gsl/gen/erbpp_gsl.rb', line 91 def init_def if n_arg != :nodef "{ VALUE c#{subtype_class} = rb_define_class_under(#{_mod_var}, \"#{subtype_class}\", #{_mod_var}); rb_define_singleton_method(c#{subtype_class}, \"new\", #{c_func}, #{n_arg}); }" end end |