Project

thanoscase

0.0
No release in over 3 years
Low commit activity in last 3 years
Randomly removes half the characters of a given string.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1, >= 2.1.4
~> 11.1, >= 11.1.3
~> 3.9
~> 0.86.0
~> 0.17.1
 Project Readme

Maintainability Test Coverage Build Status Gem Version FOSSA Status

Thanoscase

Wipes out your strings from the universe

Installation

In your gemfile:

gem 'thanoscase'

or in the console:

gem install thanoscase

Usage

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"
  • If the amount of characters is even you will get half of them as return.
      "1234".thanoscase # "14"
      "1234".thanoscase # "12"
      "1234".thanoscase # "34"
  • If the amount of characters is odd you will get half of them plus one.
      "123".thanoscase # "23"
      "123".thanoscase # "12"
      "123".thanoscase # "13"
  • If you try to apply this method to an empty string, it will return the same empty string.
      "".thanoscase # ""

You can also modify the object itself like so:

str = "Avengers"
# "Avengers"
str.thanoscase
# "Aves"
str
# "Avengers"
str.thanoscase!
# "vegr"
str
# "vegr"

License

FOSSA Status