English 中文(简体)
鲁比从指挥线阅读时改变行为
原标题:Changing behavior of gets, when reading from command line, in Ruby

下面的《鲁比法典》的预定操作如下:

  1. write ARGV[0], a file named on the command line, to old
  2. create a new, temporary copy of that file
  3. loop until user gives input
  4. remove the temporary file

当我手法的旧法等于ello门茨时,我预计,如果无人进入救援区和重复工作,它会等待3秒钟才能从关键板获得投入。

当我确定为相当于ARGV[0](也为ello.c)的旧金时,脂肪被分配到第一线,而代码则冲出。

我怎么办:

user@cpu live$ ruby test.rb hello.c 
hello.c
#include <stdio.h>
user@cpu live$

守则:

#!/usr/bin/env ruby

require  timeout 

old = ARGV[0].chomp
puts old  # sanity check
# old =  hello.c 
new =  tmp_  + old
`cp #{old} #{new}`

fp = nil
loop do
  begin
    Timeout::timeout(3) { fp = gets }
    puts fp  # sanity check
    break if (fp)
  rescue Timeout::Error
    # ...
  end
end

`rm #{new}`

我不理解,为什么从指挥线读书与硬拷贝档案名称有什么不同。

我赞赏你能够提供的任何帮助。 感谢。

最佳回答
问题回答

暂无回答




相关问题
Ruby parser in Java

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 ...

rails collection_select vs. select

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 ...

RubyCAS-Client question: Rails

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?

Ordering a hash to xml: Rails

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

multiple ruby extension modules under one directory

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 ...

Text Editor for Ruby-on-Rails

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 ...

热门标签