Method: Integer.unbooleanize
- Defined in:
- lib/wukong/extensions/emittable.rb
.unbooleanize(bool) ⇒ Object
Express boolean as 1 (true) or 0 (false). In contravention of typical ruby semantics (but in a way that is more robust for wukong-like batch processing), the number 0, the string ‘0’, nil and false are all considered false. (This also makes the method idempotent: repeated calls give same result.)
63 64 65 66 67 68 |
# File 'lib/wukong/extensions/emittable.rb', line 63 def self.unbooleanize bool case bool when 0, '0', false, nil then 0 else 1 end end |