class Discombobulator::CosmicRays::Flipper
Attributes
value[R]
Public Class Methods
new(value)
click to toggle source
# File lib/discombobulator/cosmic_rays.rb, line 41 def initialize(value) @value = value end
Public Instance Methods
call()
click to toggle source
# File lib/discombobulator/cosmic_rays.rb, line 45 def call method = [ :evil_flip, :complement, :cosmic_storm, :rescue_what_you_can, :trust_no_one ].shuffle.first send(method) end
Private Instance Methods
complement()
click to toggle source
# File lib/discombobulator/cosmic_rays.rb, line 58 def complement debug 'Complement' ~value end
cosmic_storm()
click to toggle source
# File lib/discombobulator/cosmic_rays.rb, line 63 def cosmic_storm debug 'Cosmic storm' rand(max_integer) end
debug(msg)
click to toggle source
# File lib/discombobulator/cosmic_rays.rb, line 84 def debug(msg) p msg if $DISCOMBOBULATOR_SAFETY_FEATURE == 42 end
evil_flip()
click to toggle source
# File lib/discombobulator/cosmic_rays.rb, line 53 def evil_flip debug 'Evil flip' value ^ 1 end
max_integer()
click to toggle source
# File lib/discombobulator/cosmic_rays.rb, line 78 def max_integer bytes = [42].pack('i').size bits = bytes * 16 2 ** (bits - 2) - 1 end
rescue_what_you_can()
click to toggle source
# File lib/discombobulator/cosmic_rays.rb, line 68 def rescue_what_you_can debug 'Rescue what you can' value & rand(max_integer) end
trust_no_one()
click to toggle source
# File lib/discombobulator/cosmic_rays.rb, line 73 def trust_no_one debug 'Trust no one' value ^ rand(max_integer) end