summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-11 04:01:47 +0000
committerzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-11 04:01:47 +0000
commit84247a63cecc6837febe358c4394e1752879697f (patch)
tree1f62b6e6a48abedb168c911b4aba63ea9bb7ee26 /lib
parent973d8553915756929549c53c649a86bb5f412afe (diff)
* lib/securerandom.rb: Refactor conditions by Rafal Chmiel
[Fixes GH-326] https://github.com/ruby/ruby/pull/326 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/securerandom.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/securerandom.rb b/lib/securerandom.rb
index 69fd2dddea..cc33a08044 100644
--- a/lib/securerandom.rb
+++ b/lib/securerandom.rb
@@ -51,9 +51,9 @@ module SecureRandom
n = n ? n.to_int : 16
if defined? OpenSSL::Random
- @pid = 0 if !defined?(@pid)
+ @pid = 0 unless defined?(@pid)
pid = $$
- if @pid != pid
+ unless @pid == pid
now = Time.now
ary = [now.to_i, now.nsec, @pid, pid]
OpenSSL::Random.random_add(ary.join("").to_s, 0.0)
@@ -73,7 +73,7 @@ module SecureRandom
end
@has_urandom = true
ret = f.read(n)
- if ret.length != n
+ unless ret.length == n
raise NotImplementedError, "Unexpected partial read from random device: only #{ret.length} for #{n} bytes"
end
return ret
@@ -83,7 +83,7 @@ module SecureRandom
end
end
- if !defined?(@has_win32)
+ unless defined?(@has_win32)
begin
require 'Win32API'
@@ -186,7 +186,7 @@ module SecureRandom
s = [random_bytes(n)].pack("m*")
s.delete!("\n")
s.tr!("+/", "-_")
- s.delete!("=") if !padding
+ s.delete!("=") unless padding
s
end