Class: Tk::Tcllib::ChatWidget
- Defined in:
- lib/tkextlib/tcllib/chatwidget.rb,
lib/tkextlib/tcllib/chatwidget.rb
Constant Summary collapse
- PACKAGE_NAME =
'chatwidget'.freeze
- TkCommandNames =
['::chatwidget::chatwidget'.freeze].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #add_name(nick, opts = {}) ⇒ Object
- #chat_widget ⇒ Object
- #delete_name(nick) ⇒ Object
- #entry_widget ⇒ Object
- #get_name(nick) ⇒ Object
- #hide_names ⇒ Object
- #hide_topic ⇒ Object
-
#hook_add(type, *args, &blk) ⇒ Object
args -> [prior, cmd], [prior], [cmd].
- #hook_list(type) ⇒ Object
- #hook_remove(type, cmd) ⇒ Object
- #hook_run(type, *cmd_args) ⇒ Object
- #list_name ⇒ Object
- #list_name_full ⇒ Object
- #message(msg, opts = {}) ⇒ Object
- #names_widget ⇒ Object
- #set_topic(topic) ⇒ Object
- #show_names ⇒ Object
- #show_topic ⇒ Object
Class Method Details
.package_name ⇒ Object
20 21 22 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 20 def self.package_name PACKAGE_NAME end |
Instance Method Details
#add_name(nick, opts = {}) ⇒ Object
64 65 66 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 64 def add_name(nick, opts={}) tk_send('name', 'add', nick, *(hash_kv(opts))) end |
#chat_widget ⇒ Object
149 150 151 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 149 def window(tk_send('chat')) end |
#delete_name(nick) ⇒ Object
68 69 70 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 68 def delete_name(nick) tk_send('name', 'delete', nick) end |
#entry_widget ⇒ Object
145 146 147 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 145 def window(tk_send('entry')) end |
#get_name(nick) ⇒ Object
72 73 74 75 76 77 78 79 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 72 def get_name(nick) lst = tk_send('name', 'get', nick) return nil if lst.empty? nick, *opts = tk_split_simplelist(lst) h_opt = {} opts.slice(2){|k, v| h_opt[k[1..-1]] = tk_tcl2ruby(v)} [nick, h_opt] end |
#hide_names ⇒ Object
136 137 138 139 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 136 def hide_names tk_send('names', 'hide') self end |
#hide_topic ⇒ Object
42 43 44 45 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 42 def hide_topic tk_send_without_enc('topic', 'hide') self end |
#hook_add(type, *args, &blk) ⇒ Object
args -> [prior, cmd], [prior], [cmd]
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 94 def hook_add(type, *args, &blk) # args -> [prior, cmd], [prior], [cmd] #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url' if prior = args.shift if !prior.kind_of?(Numeric) cmd = prior if (prior = args.shift) && !prior.kind_of?(Numeric) # error args.unshift(prior) end args.unshift(cmd) end prior ||= 50 # default priority end cmd = args.shift || blk fail ArgumentError, "invalid arguments" unless args.empty? fail ArgumentError, "no callback is given" unless cmd _parse_hook_list(tk_send('hook', 'add', type, cmd, prior)) end |
#hook_list(type) ⇒ Object
126 127 128 129 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 126 def hook_list(type) #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url' _parse_hook_list(tk_send('hook', 'list', type)) end |
#hook_remove(type, cmd) ⇒ Object
116 117 118 119 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 116 def hook_remove(type, cmd) #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url' _parse_hook_list(tk_send('hook', 'remove', type, cmd)) end |
#hook_run(type, *cmd_args) ⇒ Object
121 122 123 124 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 121 def hook_run(type, *cmd_args) #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url' tk_send('hook', 'run', type, *cmd_args) end |
#list_name ⇒ Object
51 52 53 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 51 def list_name tk_split_simplelist(tk_send('name', 'list')) end |
#list_name_full ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 55 def list_name_full tk_split_simplelist(tk_send('name', 'list')).map{|lst| nick, *opts = tk_split_simplelist(lst) h_opt = {} opts.slice(2){|k, v| h_opt[k[1..-1]] = tk_tcl2ruby(v)} [nick, h_opt] } end |
#message(msg, opts = {}) ⇒ Object
81 82 83 84 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 81 def (msg, opts={}) tk_send('message', msg, *(hash_kv(opts))) self end |
#names_widget ⇒ Object
141 142 143 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 141 def window(tk_send('names')) end |
#set_topic(topic) ⇒ Object
47 48 49 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 47 def set_topic(topic) tk_send('topic', 'set', topic) end |
#show_names ⇒ Object
131 132 133 134 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 131 def show_names tk_send('names', 'show') self end |
#show_topic ⇒ Object
37 38 39 40 |
# File 'lib/tkextlib/tcllib/chatwidget.rb', line 37 def show_topic tk_send_without_enc('topic', 'show') self end |