Class: Cheri::Builder::TypeConnecter::Type

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

Instance Method Summary collapse

Constructor Details

#initialize(mod) ⇒ Type

Returns a new instance of Type.



161
162
163
164
165
166
# File 'lib/cheri/builder/connecter.rb', line 161

def initialize(mod)
  raise Cheri.type_error(mod,Class,Module) unless Module === mod
  @m = mod
  @t = []
  @s = {}
end

Instance Method Details

#connect(mod, adder = nil, &k) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/cheri/builder/connecter.rb', line 168

def connect(mod,adder=nil,&k)
  raise Cheri.type_error(adder,Symbol) if adder && !(Symbol === adder)
  adder ||= :add unless k
  if Module === mod
    addm(mod,adder,&k)
  elsif Symbol === mod
    adds(mod,adder,&k)      
  elsif Array === mod
    mod.each do |m|
      if Module === m
        addm(m,adder,&k)
      elsif Symbol === m
        adds(m,adder,&k)
      else
        raise Cheri.type_error(m,Class,Module,Symbol)
      end
    end
  else
    raise Cheri.type_error(mod,Class,Module,Symbol,Array)
  end
  nil
end

#copyObject



225
226
227
# File 'lib/cheri/builder/connecter.rb', line 225

def copy
  self.class.allocate.copy_from(@m,@t,@s)    
end

#merge(other) ⇒ Object



215
216
217
218
219
220
221
222
223
# File 'lib/cheri/builder/connecter.rb', line 215

def merge(other)
  raise Cheri.type_error(other,Type) unless Type === other
  t = @t
  other.tctrs.each do |tctr| t.delete(tctr.mod); end
  t.concat(other.tctrs)
  s = @s
  other.sctrs.each do |sctr| s[sctr.sym] = sctr; end
  nil
end

#modObject



203
204
205
# File 'lib/cheri/builder/connecter.rb', line 203

def mod
  @m
end

#sctrsObject



211
212
213
# File 'lib/cheri/builder/connecter.rb', line 211

def sctrs
  @s    
end

#tctrsObject



207
208
209
# File 'lib/cheri/builder/connecter.rb', line 207

def tctrs
  @t  
end