RubyFlow The Ruby and Rails community linklog

Testing for Booleans - A New Plugin

I created a simple plugin that adds a to_b method to various classes. You can read about it here.

Comments

Nice plugin. Some notes: Ruby doesn’t evaluate 0 as false. Only nil is synonymous with false. Everything else is true. I think you’d run into some issues down the road.

Also, it would be of more use to people if it were in Gem form instead of a Rails plugin.

@bcardarella Thanks for checking it out. I know that ruby will evaluate 0 as true (0 ? true : false) => true, but the purpose of the plugin is to test whether the value of the object equates to being true or false. If you put 0 into a boolean column in your database, that’s false.

And you’re right, a gem would be better. Thanks!

Ruby Facets

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in