rcore ext

Ruby Core Extensions

3
0
Ruby

Ruby Core Extensions

Gem Version
Coverage Status
Code Climate
Dependency Status
Build Status
Bitdeli Badge

The rcore_ext gem extends several core classes

Installation

Add this line to your application’s Gemfile:

gem 'rcore-ext'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rcore-ext

Usage

Examples:

Numeric methods

"1".is_integer?             #=> true
"1.0".is_integer?           #=> false
"not_numeric".is_integer?   #=> false
"1".is_numeric?             #=> true
"1.0".is_numeric?           #=> true
"not_numeric".is_numeric?   #=> false
"1".is_float?             #=> false
"1.0".is_float?           #=> true
"not_numeric".is_float?   #=> false
"1".to_numeric                #=> 1
"1".to_numeric.class          #=> Fixnum
"1.0".to_numeric              #=> 1.0
"1.0".to_numeric.class        #=> Float
("1" * 10).to_numeric         #=> 1111111111
("1" * 10).to_numeric.class   #=> Bignum
"not_numeric".to_numeric      #=> nil 

Decode/encode methods

"hello world!".decode_string(:hex)  #=> 68656c6c6f20776f726c6421
"hi".decode_string(:bin)            #=> 0110100001101001

"NBSWY3DPEB3W64TMMQQQ====".decode_string(:base32)   #=> hello world!
"aGVsbG8gd29ybGQh\n".decode_string(:base64)         #=> hello world!  

"aGVsbG8gd29ybGQh".decode_string(:base64, strict: true) #=> hello world!
"68656c6c6f20776f726c6421".decode_string(:hex)  #=> hello world!
"0110100001101001".decode_string(:bin)          #=> hi

"hello world!".decode_string(:base32)   #=> NBSWY3DPEB3W64TMMQQQ====
"hello world!".decode_string(:base64)   #=> aGVsbG8gd29ybGQh\n  

"hello world!".decode_string(:base64, strict: true) #=> aGVsbG8gd29ybGQh  

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request