class Object
Constants
- GIGA_SIZE
/***************************************************************************
* ©2015-2016 Michael Uplawski <michael.uplawski@uplawski.eu> * * * * 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. * ***************************************************************************
- KILO_SIZE
- MEGA_SIZE
Public Instance Methods
byte_units(bytes, precision = 1)
click to toggle source
Return a formated string-version of the number in bytes. Copied from www.ruby-forum.com/topic/126876.
# 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_user()
click to toggle source
# 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