我正在使用 Visual Ruby 开发一个应用程序。我正在从如下下拉列表中获取日期:
check_to_in_1 = @builder.get_object("cellrenderertext7")
split
然后我使用以下方法拆分此日期:
date_split = check_to_in_1.text.to_s.split("/")
我这样做是因为我想将日期从转换String
为DateTime
格式,拆分后我打印如下值:
puts "#{date_split[2]}" # => 05
puts "#{date_split[1]}" # => 10
puts "#{date_split[0]}" # => 2013
现在我将此值传递给DateTime.new
方法以将其转换为DateTime
:
check_to_in_time_converted = DateTime.new(date_split[0],
date_split[1], date_split[2])
现在在这里我得到了这个错误:
C:/Users/abhiram/visualruby/examples/fedena/bin/SendAbsentees.rb:213:in `new': undefined method `div' for "05":String
from C:/Users/abhiram/visualruby/examples/fedena/bin/SendAbsentees.rb:213:in `button1_clicked'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/gtk2-1.2.1-x86-mingw32/lib/gtk2/base.rb:95:in `call'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/gtk2-1.2.1-x86-mingw32/lib/gtk2/base.rb:95:in `block in __connect_signals__'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/vrlib-0.0.33/lib/GladeGUI.rb:331:in `call'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/vrlib-0.0.33/lib/GladeGUI.rb:331:in `main'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/vrlib-0.0.33/lib/GladeGUI.rb:331:in `show_window'
from C:/Users/abhiram/visualruby/examples/fedena/bin/SendAbsentees.rb:99:in `show'
from C:/Users/abhiram/visualruby/examples/fedena/bin/Control.rb:36:in `button2_clicked'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/gtk2-1.2.1-x86-mingw32/lib/gtk2/base.rb:95:in `call'
我不知道从这里该怎么办,有人可以帮我摆脱困境吗?