Class: Integer

Inherits:
Object
  • Object
show all
Defined in:
lib/rantly/shrinks.rb

Overview

Integer : shrink to zero

Instance Method Summary collapse

Instance Method Details

#retry?Boolean


18
19
20
# File 'lib/rantly/shrinks.rb', line 18

def retry?
  false
end

#shrinkObject


3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rantly/shrinks.rb', line 3

def shrink
  shrunk = if self > 8
    self / 2
  elsif self > 0
    self - 1
  elsif self < -8
    (self + 1) / 2
  elsif self < 0
    self + 1
  else
    0
  end
  return shrunk
end

#shrinkable?Boolean


22
23
24
# File 'lib/rantly/shrinks.rb', line 22

def shrinkable?
  self != 0
end