Class: TTK::SymTbl

Inherits:
SymTbl show all
Includes:
DRb::DRbUndumped, Mutex_m
Defined in:
lib/ttkd.rb,
lib/ttk/symtbl.rb

Instance Method Summary collapse

Methods inherited from SymTbl

#symtbl_gsub

Constructor Details

#initialize(father_env = nil, default = nil) ⇒ SymTbl

Returns a new instance of SymTbl.



13
14
15
16
# File 'lib/ttk/symtbl.rb', line 13

def initialize ( father_env=nil, default=nil )
  @frozen_keys = []
  super
end

Instance Method Details

#[](aKey) ⇒ Object



18
19
20
# File 'lib/ttk/symtbl.rb', line 18

def [] ( aKey )
  super
end

#[]=(k, v) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/ttk/symtbl.rb', line 22

def []= ( k, v )
  if frozen_key?(k)
    raise(TypeError, 'can\'t modify frozen key')
  else
    super
  end
end

#freeze_key(k) ⇒ Object



34
35
36
37
38
39
# File 'lib/ttk/symtbl.rb', line 34

def freeze_key ( k )
  unless frozen_key?(k)
    @frozen_keys << k
    self[k].freeze
  end
end

#frozen_key?(k) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/ttk/symtbl.rb', line 30

def frozen_key? ( k )
  @local.has_key?(k) and @frozen_keys.include?(k)
end