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.



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

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



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

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


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

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



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

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

#nameObject



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

def name
  @id
end

#to_evalObject



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

def to_eval
  @id
end