Top Level Namespace

Defined Under Namespace

Modules: File_Checking, Logging Classes: ArgParser, BusyIndicator, Download, DownloadHistory, DownloadProgress, Network, Rget, TClass

Constant Summary collapse

GIGA_SIZE =

/***************************************************************************

*   ©2015-2016 Michael Uplawski <[email protected]>            *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 3 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         *
*   This program is distributed in the hope that it will be useful,       *
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
*   GNU General Public License for more details.                          *
*                                                                         *
*   You should have received a copy of the GNU General Public License     *
*   along with this program; if not, write to the                         *
*   Free Software Foundation, Inc.,                                       *
*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
***************************************************************************
1073741824.0
MEGA_SIZE =
1048576.0
KILO_SIZE =
1024.0

Instance Method Summary collapse

Instance Method Details

#byte_units(bytes, precision = 1) ⇒ Object

Return a formated string-version of the number in bytes. Copied from www.ruby-forum.com/topic/126876.


29
30
31
32
33
34
35
36
37
# File 'lib/util.rb', line 29

def byte_units(bytes, precision = 1)
	case
	when bytes == 1 then "1 Byte"
	when bytes < KILO_SIZE then "%d Bytes" % bytes
	when bytes < MEGA_SIZE then "%.#{precision}f K" % (bytes / KILO_SIZE)
	when bytes < GIGA_SIZE then "%.#{precision}f M" % (bytes / MEGA_SIZE)
	else "%.#{precision}f GB" % (bytes / GIGA_SIZE)
	end
end

#wait_for_userObject


27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/user_input.rb', line 27

def wait_for_user()
	# @log.debug('wait_for_user() ')
	char = nil
	STDIN.raw do 
		STDIN.noecho do
			until (STDIN.ready?)
				sleep(0.1)
			end

			char = (STDIN.read_nonblock(1).ord rescue nil)
		end
	end
	return char
end