Skip to content

EdwinRozario/ArrayBooster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

ArrayBooster Gem:

Adds a few more features to a Ruby array. Array can be used like a Queue with rpush, lpush, rpop and lpop. A feature substitute is also added, which allows to substitute a element in the array with another. Data can be pushed to an array with priority with ppush.

Installation

gem install arraybooster

Use

require 'arraybooster'

subject = ['CaptainAmerica', 'Thor', 'HawkEye', 'Hulk', 'IronMan', 'WonderWoman']

subject.lpush('SuperMan') #Push 'Superman' to the left of the array
['SuperMan', 'CaptainAmerica', 'Thor', 'HawkEye', 'Hulk', 'IronMan', 'WonderWoman']

subject.rpush('AntMan') #Push 'Antman' to the right of the array
['SuperMan', 'CaptainAmerica', 'Thor', 'HawkEye', 'Hulk', 'IronMan', 'WonderWoman', 'AntMan']

subject.lpop #Pop from left of the array. arrayname.lpop(n) will pop n elements
'SuperMan'
['CaptainAmerica', 'Thor', 'HawkEye', 'Hulk', 'IronMan', 'WonderWoman', 'AntMan']

subject.rpop #Pop from right of the array. arrayname.rpop(n) will pop n elements
'AntMan'
['CaptainAmerica', 'Thor', 'HawkEye', 'Hulk', 'IronMan', 'WonderWoman']

subject.ppush('Wasp', 2) #Push 'Wasp' with priority 2. So its placed at second position.
['CaptainAmerica', 'Wasp', 'Thor', 'HawkEye', 'Hulk', 'IronMan', 'WonderWoman']

subject.substitute('WonderWoman', 'BlackWidow') #Replaces 'WonderWoman' with 'BlackWidow' from the arry.
['CaptainAmerica', 'Thor', 'HawkEye', 'Hulk', 'IronMan', 'BlackWidow']

names = ["edwin", "edmond", "eddie", "edward", "amanda", "anand", "calwin"]

names.similars("edwardo") #Finds all elements similar to input. All elemets are considered as string while this operation.
["edwin", "edmond", "eddie", "edward"]

names.similars("melwin")
["edwin", "calwin"]

About

Extention of Ruby Array

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages