Class: SKKHub::SKKSERVDic
- Inherits:
-
Object
- Object
- SKKHub::SKKSERVDic
- Defined in:
- lib/skkhub.rb
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(host, port) ⇒ SKKSERVDic
constructor
A new instance of SKKSERVDic.
- #search(q) ⇒ Object
Constructor Details
#initialize(host, port) ⇒ SKKSERVDic
Returns a new instance of SKKSERVDic.
48 49 50 |
# File 'lib/skkhub.rb', line 48 def initialize(host, port) @host, @port = host, port end |
Instance Method Details
#get ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/skkhub.rb', line 65 def get io = TCPSocket.new(@host, @port) a = yield io io.shutdown io.close a end |
#search(q) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/skkhub.rb', line 52 def search(q) get do |io| io.syswrite("1#{q.encode('EUC-JP')} \n") r, s = [io], "" while IO.select(r) s << io.sysread(512) break if s[-1, 1] == "\n" end s.force_encoding('EUC-JP') s[2..-3].split("/") if s[0, 1] == '1' end end |