Sha256: 810262b5b38f42fee508fd3b4a3081ebc5c2c4395bde7f18d8ebd4d56cae71ce

Contents?: true

Size: 505 Bytes

Versions: 1

Compression:

Stored size: 505 Bytes

Contents

# -*- encoding: utf-8 -*-

# Numeric extensions

class Numeric


 # @return 0 if the given flag is any of: nil, false, 0, [], {}
 #
 # @example
 #   3.if(true) => 3
 #   3.if(false) => 0
 #   

 def if(flag)
   if [nil,false,0,[],{}].include?(flag) then 0 else self end
 end


 # @return self if flag is nil, false, 0, [], {}; otherwise return 0.
 #
 # @example
 #   3.unless(true) => 0
 #   3.unless(false) => 3

 def unless(flag)
   if [nil,false,0,[],{}].include?(flag) then self else 0 end
 end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webget_ruby_ramp-1.8.2 lib/webget_ruby_ramp/numeric.rb