| Line | |
|---|
| 1 | #!/usr/bin/env ruby |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | require "irb" |
|---|
| 5 | require "irb/completion" |
|---|
| 6 | |
|---|
| 7 | data = DATA.read.split(/\n/) |
|---|
| 8 | Readline.completion_proc = proc {|word| |
|---|
| 9 | if word.empty? |
|---|
| 10 | [ data.shift ] |
|---|
| 11 | else |
|---|
| 12 | IRB::InputCompletor::CompletionProc.call(word) |
|---|
| 13 | end |
|---|
| 14 | } |
|---|
| 15 | Readline.completion_append_character = "" |
|---|
| 16 | Readline.completion_case_fold = true |
|---|
| 17 | |
|---|
| 18 | if __FILE__ == $0 |
|---|
| 19 | IRB.start(__FILE__) |
|---|
| 20 | else |
|---|
| 21 | # check -e option |
|---|
| 22 | if /^-e$/ =~ $0 |
|---|
| 23 | IRB.start(__FILE__) |
|---|
| 24 | else |
|---|
| 25 | IRB.setup(__FILE__) |
|---|
| 26 | end |
|---|
| 27 | end |
|---|
| 28 | |
|---|
| 29 | __END__ |
|---|
| 30 | require "future" |
|---|
| 31 | class Foo |
|---|
| 32 | def omoi(n) |
|---|
| 33 | sleep n |
|---|
| 34 | n |
|---|
| 35 | end |
|---|
| 36 | end |
|---|
| 37 | f = Foo.new |
|---|
| 38 | f.omoi(1) |
|---|
| 39 | f.async.omoi(1); nil |
|---|
| 40 | r = f.async.omoi(5); nil |
|---|
| 41 | r |
|---|
| 42 | r = f.async.omoi(3); nil |
|---|
| 43 | # ちょっとまつ |
|---|
| 44 | r |
|---|