Class: Cheri::Builder::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/cheri/builder/generator.rb

Defined Under Namespace

Modules: Template Classes: AutoFactory, CheriYieldBuilder, CherifyBuilder, EvalBuilder, TypeBuilder, TypeFactory

Constant Summary collapse

CamelCase =

AutoFactory

/([a-z])([A-Z])/
RubyCase =

:nodoc:

'\1_\2'
Sep =

:nodoc:

'::'

Instance Method Summary collapse

Constructor Details

#initialize(*r, &k) ⇒ Generator

Returns a new instance of Generator.

Raises:

  • (ArgumentError)


154
155
156
157
158
159
# File 'lib/cheri/builder/generator.rb', line 154

def initialize(*r,&k)
  raise ArgumentError,"no args or block supplied" unless k || !r.empty?
  raise ArgumentError,"no arguments permitted when block supplied" if k && !r.empty?
  @args = r
  @blk = k if k
end

Instance Method Details

#runObject



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/cheri/builder/generator.rb', line 161

def run
  if @blk
    eb = EvalBuilder.new(&@blk)
    create_mod(eb)
  else
    # _really_ simple builder
    @types = BuildTypes.new
    @ctr = TypeConnecter.new
    if Hash === @args.last
      @args.pop.each_pair do |clazz,adder|
        add_type(clazz,nil,adder)        
      end      
    end
    @args.each do |clazz|
      add_type(clazz)
    end
    create_simple_mod
  end
end