Class: DefLib

Inherits:
ErbPP show all
Defined in:
ext/cumo/narray/gen/erbpp2.rb

Instance Attribute Summary

Attributes inherited from ErbPP

#children, #parent

Instance Method Summary collapse

Methods inherited from ErbPP

#add_child, #description, #find, #find_tmpl, #get, #init_def, #load_erb, #method_missing, #method_missing_alias, #result, #run, #set, #write

Constructor Details

#initialize(parent = nil, **opts, &block) ⇒ DefLib

Returns a new instance of DefLib.



122
123
124
125
126
# File 'ext/cumo/narray/gen/erbpp2.rb', line 122

def initialize(parent=nil, **opts, &block)
  opts[:erb_base] ||= 'lib'
  opts[:include_files] ||= []
  super(parent, **opts, &block)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ErbPP

Instance Method Details

#cumo_id_assignObject



127
128
129
130
131
# File 'ext/cumo/narray/gen/erbpp2.rb', line 127

def cumo_id_assign
  ids = []
  @children.each{|c| a=c.get(:cumo_id_list); ids.concat(a) if a}
  ids.sort.uniq.map{|x| "cumo_id_#{x[1]} = rb_intern(\"#{x[0]}\");"}
end

#cumo_id_declObject



132
133
134
135
136
# File 'ext/cumo/narray/gen/erbpp2.rb', line 132

def cumo_id_decl
  ids = []
  @children.each{|c| a=c.get(:cumo_id_list); ids.concat(a) if a}
  ids.sort.uniq.map{|x| "static ID cumo_id_#{x[1]};\n"}
end

#def_class(**opts, &block) ⇒ Object



137
138
139
# File 'ext/cumo/narray/gen/erbpp2.rb', line 137

def def_class(**opts, &block)
  DefClass.new(self, **opts, &block)
end

#def_module(**opts, &block) ⇒ Object



140
141
142
# File 'ext/cumo/narray/gen/erbpp2.rb', line 140

def def_module(**opts, &block)
  DefModule.new(self, **opts, &block)
end