Class: TkBindTag

Inherits:
Object show all
Includes:
TkBindCore
Defined in:
lib/tk/bindtag.rb

Direct Known Subclasses

TkBindTagAll, TkDatabaseClass

Constant Summary collapse

BTagID_TBL =

BTagID_TBL = {}

TkCore::INTERP.create_table
ALL =
self.new_by_name('all')

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TkBindCore

#bind, #bind_append, #bind_remove, #bindinfo

Constructor Details

#initialize(*args, &b) ⇒ TkBindTag

Returns a new instance of TkBindTag.



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/tk/bindtag.rb', line 60

def initialize(*args, &b)
  Tk_BINDTAG_ID.mutex.synchronize{
    # @id = Tk_BINDTAG_ID.join('')
    @id = Tk_BINDTAG_ID.join(TkCore::INTERP._ip_id_)
    Tk_BINDTAG_ID[1].succ!
  }
  BTagID_TBL.mutex.synchronize{
    BTagID_TBL[@id] = self
  }
  bind(*args, &b) if args != []
end

Class Method Details

.id2obj(id) ⇒ Object



22
23
24
25
26
# File 'lib/tk/bindtag.rb', line 22

def TkBindTag.id2obj(id)
  BTagID_TBL.mutex.synchronize{
    (BTagID_TBL[id])? BTagID_TBL[id]: id
  }
end

.new_by_name(name, *args, &b) ⇒ Object

def TkBindTag.new_by_name(name, *args, &b)

  BTagID_TBL.mutex.synchronize{
    return BTagID_TBL[name] if BTagID_TBL[name]
  }

  self.new.instance_eval{
    BTagID_TBL.mutex.synchronize{
      BTagID_TBL.delete @id
      @id = name
      BTagID_TBL[@id] = self
    }
    bind(*args, &b) if args != []
    self
  }
end


45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/tk/bindtag.rb', line 45

def TkBindTag.new_by_name(name, *args, &b)
  obj = nil
  BTagID_TBL.mutex.synchronize{
    if BTagID_TBL[name]
      obj = BTagID_TBL[name]
    else
      (obj = BTagID_TBL[name] = self.allocate).instance_eval{
        @id = name
      }
    end
  }
  bind(*args, &b) if obj && args != []
  obj
end

Instance Method Details

#inspectObject



82
83
84
85
# File 'lib/tk/bindtag.rb', line 82

def inspect
  #Kernel.format "#<TkBindTag: %s>", @id
  '#<TkBindTag: ' + @id + '>'
end

#nameObject



74
75
76
# File 'lib/tk/bindtag.rb', line 74

def name
  @id
end

#to_evalObject



78
79
80
# File 'lib/tk/bindtag.rb', line 78

def to_eval
  @id
end