This gem provides String#present and String#blank.
Add this line to your application's Gemfile:
gem 'string-present-blank'
And then execute:
$ bundle
Or install it yourself as:
$ gem install string-present-blank
# before
'abc' + 'efg' #=> 'abcefg'
'abc' + 'efg' if false #=> nil
'abc' + ('efg' if false) #=> TypeError: no implicit conversion of nil into String
'abc' + if false then 'efg' else '' end #=> 'abc'
# after
'abc' + 'efg'.blank(if: false) #=> 'abc'
'abc' + 'efg'.present(unless: false) #=> 'abc'
- Fork it ( https://github.com/[my-github-username]/string-present-blank/fork )
- 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 a new Pull Request