我想读到一个档案,并显示它的规模。 页: 1 并改变我投入文件的规模。 因此,现在的日志。 每一艘船都有拖拉机。 什么进展?
logfile = open(input_fspec)
puts "logfile size: #{logfile.count} lines"
我想读到一个档案,并显示它的规模。 页: 1 并改变我投入文件的规模。 因此,现在的日志。 每一艘船都有拖拉机。 什么进展?
logfile = open(input_fspec)
puts "logfile size: #{logfile.count} lines"
<代码>s将读到输入中的所有线,以便进行计票。 请再次读到这些行文(例如,使用<条码>><>>>>>/代码>或<条码>each)。 然后,您需要打上<代码>logfile.rewind,以便重新开始档案。
事实上,<代码>上<>s/code>正在实际返回的是尚未读到的线数。 例如,如果你已经通过卷宗读到,然后打电话到count<>/code>,那么就会回去0。
否则,你就可以这样做,甚至听任:
File.size("input_fspec")
The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...
collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...
All of the following API do the same thing: open a file and call a block for each line. Is there any preference we should use one than another? File.open("file").each_line {|line| puts line} open("...
I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?
Here s the string: 04046955104021109 I need it to be formatted like so: 040469551-0402-1109 What s the shortest/most efficient way to do that with ruby?
I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml
Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...
guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...