Class: DefLib

Inherits:
ErbPP show all
Defined in:
ext/numo/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.



115
116
117
118
119
# File 'ext/numo/narray/gen/erbpp2.rb', line 115

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

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



130
131
132
# File 'ext/numo/narray/gen/erbpp2.rb', line 130

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

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



133
134
135
# File 'ext/numo/narray/gen/erbpp2.rb', line 133

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

#id_assignObject



120
121
122
123
124
# File 'ext/numo/narray/gen/erbpp2.rb', line 120

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

#id_declObject



125
126
127
128
129
# File 'ext/numo/narray/gen/erbpp2.rb', line 125

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