rb_core_extensions
is a set of core extensions beyond those provided by Ruby
and ActiveSupport
.
- Ruby 3.2.2+ (https://www.ruby-lang.org/en/downloads/branches/)
If using bundler, first add this line to your application's Gemfile:
gem 'rb_core_extensions'
And then execute:
$ bundle install
Or otherwise simply install it yourself as:
$ gem install rb_core_extensions
Loading all core extensions at once:
require "core_extensions/all"
Cherry-picking only what you want:
require "core_extensions/array"
require "core_extensions/array/math"
require "core_extensions/date"
Below are the extension methods provided by rb_core_extensions
. Please refer documentation for examples of how to use these methods.
#take!
- Alters the array by removing firstn
elements.
round
- Rounds each element of the numeric array up to specifiedprecision
.mean
- Returns the mean of the array ofNumeric
.variance
- Returns the variance of the array ofNumeric
.stddev
- Returns the standard deviation of the array ofNumeric
.
duplicates
- Returns an array of the duplicate elements.
include_any?
- Returns whether the array contains any of theelements
.include_none?
- Returns whether the array contains none of theelements
.include_all?
- Returns whether the array contains all of theelements
.includes_index?
- Returns whether the array has a value at the specifiedindex
.
#keys?
- Returns whether the hash contains all of the specifiedkeys
.
#keys_at
- Returns the array of keys of an occurrence of givenvalues
.
#slice!
- Alters the hash by keeping only specifiedkeys
and returns it.
#to_i
- Returns1
if invoked onTrueClass
instance.#to_b
- Returnstrue
if invoked onTrueClass
instance.
#to_i
- Returns0
if invoked onFalseClass
instance.#to_b
- Returnsfalse
if invoked onFalseClass
instance.
#blank?
- Returnstrue
if invoked onNilClass
instance.#to_b
- Returnsfalse
if invoked onNilClass
instance.
#is_one_of?
- Returnstrue
if the receiver object is an instance of at least one of the classes specified byargs
.#deep_send
- Invokes the specified methods continuously, unless encountering anil
value.#in_namespace?
- Returns whether or not the object is in the given namespace.
#namespaces
- Returns anArray
with the namespaces to the currentModule
.
#hierarchy
- Returns a tree-likeHash
structure of all descendants.#lineage
- Returns anArray
of all superclasses.#leaf_subclasses
- Returns anArray
of all descendants which have no subclasses.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Copyright 2023 Harshal V. LADHE, Released under the MIT License.