Utilise

Code Climate Build Status Dependency Status Coverage Status Gem Version

Extends classes to include the to_bool method

Currently extends:

  • Fixnum
  • String
  • Symbol
  • Hash
  • Array
  • Object

New Classes

  • Hashie::Bash

Hashes and Arrays will have all values iterated.

Usage

gem install utilise
require 'utilise'

to_bool

1.to_bool
=> true

'yes'.to_bool
=> true

:t.to_bool
=> true

{'key' => 1}.to_bool
=> {'key' => true}

[1].to_bool
=> [true]
0.to_bool
=> false

'no'.to_bool
=> false

:f.to_bool
=> false

{'key' => 0}.to_bool
=> {'key' => false}

[0].to_bool
=> [false]

Time#unique

Time.unique
=> '80347765'

bool?

true.bool?
=> true

false.bool?
=> true

1.bool?
=> false

'true'.bool?
=> false

string cases

'snake_case'.camel
=> 'SnakeCase'

'kebab-case'.camel(:lower)
=> 'kebabCase'

'space case'.snake
=> 'space_case'

'CamelCase'.space
=> 'camel case'

'camelCase'.kebab
=> 'camel-case'