Class: Cheri::Builder::TypeConnecter::Sym
- Inherits:
-
Object
- Object
- Cheri::Builder::TypeConnecter::Sym
- Defined in:
- lib/cheri/builder/connecter.rb
Overview
Type
Instance Method Summary collapse
- #connect(sym, adder = nil, &k) ⇒ Object
- #copy ⇒ Object
-
#initialize(sym) ⇒ Sym
constructor
A new instance of Sym.
- #merge(other) ⇒ Object
- #sctrs ⇒ Object
- #sym ⇒ Object
- #tctrs ⇒ Object
Constructor Details
#initialize(sym) ⇒ Sym
Returns a new instance of Sym.
240 241 242 243 244 245 |
# File 'lib/cheri/builder/connecter.rb', line 240 def initialize(sym) raise Cheri.type_error(sym,Symbol) unless Symbol === sym @m = sym @t = [] @s = {} end |
Instance Method Details
#connect(sym, adder = nil, &k) ⇒ Object
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/cheri/builder/connecter.rb', line 247 def connect(sym,adder=nil,&k) raise Cheri.type_error(adder,Symbol) if adder && !(Symbol === adder) adder ||= :add unless k if Symbol === sym adds(sym,adder,&k) elsif Module === sym addm(sym,adder,&k) elsif Array === sym sym.each do |m| if Symbol === m adds(m,adder,&k) elsif Module === m addm(m,adder,&k) else raise Cheri.type_error(m,Symbol,Class,Module) end end else raise Cheri.type_error(sym,Symbol,Class,Module,Array) end nil end |
#copy ⇒ Object
304 305 306 |
# File 'lib/cheri/builder/connecter.rb', line 304 def copy self.class.allocate.copy_from(@m,@t,@s) end |
#merge(other) ⇒ Object
294 295 296 297 298 299 300 301 302 |
# File 'lib/cheri/builder/connecter.rb', line 294 def merge(other) raise Cheri.type_error(other,Sym) unless Sym === 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 |
#sctrs ⇒ Object
290 291 292 |
# File 'lib/cheri/builder/connecter.rb', line 290 def sctrs @s end |
#sym ⇒ Object
282 283 284 |
# File 'lib/cheri/builder/connecter.rb', line 282 def sym @m end |
#tctrs ⇒ Object
286 287 288 |
# File 'lib/cheri/builder/connecter.rb', line 286 def tctrs @t end |