Project

notty

0.0
No commit activity in last 3 years
No release in over 3 years
This ridiculous gem inspired by the epic pull request thread at https://github.com/rails/rails/pull/258.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 2.4.0
 Project Readme

Notty¶ ↑

It became clear to me, after reviewing a recent Rails pull request, that when dealing with “interrogation” methods (that is, methods intended to return a true/false value, answering some question about an object), Ruby is simply not expressive enough on its own.

Sure, Array#empty? is handy. But what if we want to know if our array is not empty? Should we really be expected to write:

![1, 2, 3].empty?
# or...
not [1, 2, 3].empty?

Perish the thought! We Rubyists, always moving forward toward greater levels of expression in our code, can do better than this.

How about [1,2,3].full? Well, that would be expressive, but it’s not expressing the right thing. You see, the array isn’t full, it’s just not empty!

Enter Notty. Simply add Notty to your project’s Gemfile, and you’ll never face the issue of non-expressiveness again.

Let’s tackle that non-empty array problem once again, this time with the power of Notty behind us.

[1, 2, 3].not_empty? # => true

Awesome! Overflowing with expressiveness.

But wait, there’s more!¶ ↑

What if we want to see if the opposite is true? No problem!

[1, 2, 3].not_not_empty? # => false

Easy!

In fact, as you can see from these examples from Notty’s extensive test suite, the possibilities are limitless (preceding “limitless” claim is subject to platform callstack depth):

it 'negates frozen?' do
  @o.not_frozen?.should be_true
end

it 'negates negated frozen?' do
  @o.not_not_frozen?.should be_false
end

it 'negates negated negated frozen?' do
  @o.not_not_not_frozen?.should be_true
end

it 'negates negated negated negated frozen?' do
  @o.not_not_not_not_frozen?.should be_false
end

it 'negates negated negated negated negated frozen?' do
  @o.not_not_not_not_not_frozen?.should be_true
end

it 'negates negated negated negated negated  negated frozen?' do
  @o.not_not_not_not_not_not_frozen?.should be_false
end

Install Notty today. Go forth, and express yourself! Or not!