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.



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

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



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

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



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

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



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

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

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



142
143
144
# File 'ext/cumo/narray/gen/erbpp2.rb', line 142

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