1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/tk/lib/tk/variable.rb: add TkVariable#to_hash,to_proc,to_int,to_str,to_ary

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagai 2009-10-03 20:39:54 +00:00
parent 7f80452c21
commit 85b326ac42
2 changed files with 26 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Sun Oct 4 05:34:34 2009 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk/variable.rb: add TkVariable#to_hash,to_proc,to_int,
to_str,to_ary
Sun Oct 4 00:59:52 2009 Takeyuki FUJIOKA <xibbar@ruby-lang.org>
* lib/cgi/core.rb: fix command-line option of

View file

@ -694,6 +694,14 @@ end
self
end
def to_hash
hash = {}
self.keys.each{|k|
hash[k] = self[k]
}
hash
end
def set_element_value(idxs, val)
if idxs.kind_of?(Array)
self[*idxs]=val
@ -921,9 +929,20 @@ end
self.set_proceure_element(idxs, cmd)
end
def to_proc
cmd = self.procedure
if cmd.respond_to?(:call)
cmd
else
# cmd is a String
cmd.to_sym.to_proc
end
end
def to_i
number(_value).to_i
end
alias to_int to_i
def element_to_i(*idxs)
number(_element_value(*idxs)).to_i
end
@ -940,6 +959,7 @@ end
_value
end
alias string to_s
alias to_str to_s
def element_to_s(*idxs)
_element_value(*idxs)
end
@ -1011,6 +1031,7 @@ end
tk_split_simplelist(_value)
end
alias to_a list
alias to_ary list
def list_element(*idxs)
tk_split_simplelist(_element_value(*idxs))
end