66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/simplescrambler.rb', line 66
def scramble(min = 10, max = 100)
if self.to_s.length == 1
raise CannotScrambleNumberDigit
elsif self.to_s.chars.count(self.to_s.chars[0]) == self.to_s.length
raise CannotScrambleNumberSame
elsif max.class != Integer || min.class != Integer
raise NotNumber
else
temp = self.to_s.chars
temp.delete(".")
temp = temp.join.scramble(min, max).chars
temp.insert((1 + rand(temp.length - 1)), ".")
return temp.join.to_f
end
end
|