From 73349fe70303807f15719c4c6ba5148ace20ba1a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Mar 2012 23:13:51 +0100 Subject: [PATCH] shortened and speedup code - removed method #displays which was just called from within the class --- lib/X11/auth.rb | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/X11/auth.rb b/lib/X11/auth.rb index bf51a8a..8ac62f5 100644 --- a/lib/X11/auth.rb +++ b/lib/X11/auth.rb @@ -40,10 +40,13 @@ module X11 address = TCPSocket.gethostbyname(host) if family == :Internet # this line does nothing for now auth_data = nil - displays.each do |entry| - auth_data = entry if display_id.to_i == entry.display.to_i + + # with each entry from XAuthority file + until @file.eof? + r = read() + auth_data = r if display_id.to_i == f.display.to_i end - + reset return auth_data end @@ -56,14 +59,6 @@ module X11 AuthInfo[*auth_info] end - # returns all entries from XAuthority file - def displays - collection = [] - collection << read while !@file.eof? - reset - collection - end - def reset @file.seek(0, IO::SEEK_SET) end