Sha256: cba7d671c67dfe125f60607e16e3f83862c0a9572f805ff5669d6c56d8057b06

Contents?: true

Size: 393 Bytes

Versions: 5

Compression:

Stored size: 393 Bytes

Contents

# JsonLogic truthy / falsy logic
# Cf. http://jsonlogic.com/truthy.html

class Object
  def truthy?
    !falsy?
  end

  def falsy?
    false
  end
end

class NilClass
  def falsy?
    true
  end
end

class FalseClass
  def falsy?
    true
  end
end

class String
  def falsy?
    empty?
  end
end

class Integer
  def falsy?
    zero?
  end
end

class Array
  def falsy?
    empty?
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
json_logic-0.4.1 lib/json_logic/truthy.rb
json_logic-0.4.0 lib/json_logic/truthy.rb
json_logic-0.3 lib/json_logic/truthy.rb
json_logic-0.1 lib/json_logic/truthy.rb
json_logic-0.0.1 lib/json_logic/truthy.rb