回答編集履歴
1
追記
test
CHANGED
@@ -13,3 +13,59 @@
|
|
13
13
|
お書きのリンク先とは全く関係ないことが分かるでしょう。
|
14
14
|
|
15
15
|
このプログラムの場合だと、入力待ちです。
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
#追記:selectの機能
|
20
|
+
|
21
|
+
その1:
|
22
|
+
|
23
|
+
```Ruby
|
24
|
+
|
25
|
+
input = select([STDIN],nil,nil,5) # 入力がなくても5秒でタイムアウト
|
26
|
+
|
27
|
+
p input
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
if input and input[0][0]
|
32
|
+
|
33
|
+
p input[0][0].gets
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
```
|
38
|
+
|
39
|
+
その1の1:起動5秒以内に、何か入力してEnter
|
40
|
+
|
41
|
+
その1の2:起動後5秒待つ
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
その2:
|
46
|
+
|
47
|
+
```Ruby
|
48
|
+
|
49
|
+
sleep 5
|
50
|
+
|
51
|
+
puts "select start at #{Time.now}"
|
52
|
+
|
53
|
+
input = select([STDIN]) # 入力がなければ待つ
|
54
|
+
|
55
|
+
puts "select end at #{Time.now}"
|
56
|
+
|
57
|
+
p input
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
if input and input[0][0]
|
62
|
+
|
63
|
+
p input[0][0].gets
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
```
|
68
|
+
|
69
|
+
その2の1:起動5秒以内のSleepの間に、何か入力してEnter
|
70
|
+
|
71
|
+
その2の2:起動5秒以降で、selectが始まってから、何か入力してEnter
|