Randomly removes half the characters of a given string
MIT License
Wipes out your strings from the universe
In your gemfile:
gem 'thanoscase'
or in the console:
gem install thanoscase
This gem MonkeyPatches the String class for adding two new methods:
class String
def thanoscase!
return self if empty?
half_universe = length/2
half_universe.times { slice!(rand(length)) }
self
end
def thanoscase
dup.thanoscase!
end
end
It will randomly eliminate half the characters you have in the string:
"Marvel Universe".thanoscase # "arel Uve"
"Marvel Universe".thanoscase # "rvlUners"
"Marvel Universe".thanoscase # "Marel ie"
"1234".thanoscase # "14"
"1234".thanoscase # "12"
"1234".thanoscase # "34"
"123".thanoscase # "23"
"123".thanoscase # "12"
"123".thanoscase # "13"
"".thanoscase # ""
You can also modify the object itself
like so:
str = "Avengers"
# "Avengers"
str.thanoscase
# "Aves"
str
# "Avengers"
str.thanoscase!
# "vegr"
str
# "vegr"