Class: TTK::SymTbl
- Includes:
- DRb::DRbUndumped, Mutex_m
- Defined in:
- lib/ttkd.rb,
lib/ttk/symtbl.rb
Instance Method Summary collapse
- #[](aKey) ⇒ Object
- #[]=(k, v) ⇒ Object
- #freeze_key(k) ⇒ Object
- #frozen_key?(k) ⇒ Boolean
-
#initialize(father_env = nil, default = nil) ⇒ SymTbl
constructor
A new instance of SymTbl.
Methods inherited from SymTbl
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
30 31 32 |
# File 'lib/ttk/symtbl.rb', line 30 def frozen_key? ( k ) @local.has_key?(k) and @frozen_keys.include?(k) end |