Sha256: d6cc68270fbe211fc5a5e11ce2e4a2b07a3cf21af1cbf3db9be41ccda51d2348

Contents?: true

Size: 439 Bytes

Versions: 5

Compression:

Stored size: 439 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 Float
  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.7 lib/json_logic/truthy.rb
json_logic-0.4.6 lib/json_logic/truthy.rb
json_logic-0.4.5 lib/json_logic/truthy.rb
json_logic-0.4.4 lib/json_logic/truthy.rb
json_logic-0.4.3 lib/json_logic/truthy.rb