Giter VIP home page Giter VIP logo

demo_thanoscase's Introduction

Demo Thanoscase

Wipes out your strings from the universe

Installation

In your gemfile:

gem 'demo_thanoscase', '~> 0.0.1'

or in the console:

gem install demo_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"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.