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 firstnelements.
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 specifiedkeysand returns it.
#to_i- Returns1if invoked onTrueClassinstance.#to_b- Returnstrueif invoked onTrueClassinstance.
#to_i- Returns0if invoked onFalseClassinstance.#to_b- Returnsfalseif invoked onFalseClassinstance.
#blank?- Returnstrueif invoked onNilClassinstance.#to_b- Returnsfalseif invoked onNilClassinstance.
#is_one_of?- Returnstrueif the receiver object is an instance of at least one of the classes specified byargs.#deep_send- Invokes the specified methods continuously, unless encountering anilvalue.#in_namespace?- Returns whether or not the object is in the given namespace.
#namespaces- Returns anArraywith the namespaces to the currentModule.
#hierarchy- Returns a tree-likeHashstructure of all descendants.#lineage- Returns anArrayof all superclasses.#leaf_subclasses- Returns anArrayof 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.