Sha256: 4ff9ad8adca3c5fe81cef88c79c698e052eeedac9d98715afc5568e0faab3894

Contents?: true

Size: 776 Bytes

Versions: 26

Compression:

Stored size: 776 Bytes

Contents

class Object

  # Tests to see if something has value. An object
  # is considered to have value if it is not nil?
  # and if it responds to #empty?, i snot.
  #
  def val?
    return false if nil?
    return false if empty? if respond_to?(:empty?)
    true
  end

end


#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TCKernel < Test::Unit::TestCase

    def test_val_1
      f = nil
      t = 1
      assert( ! f.val? )
      assert( t.val? )
    end

    def test_val_2
      f = []
      t = [1]
      assert( ! f.val? )
      assert( t.val? )
    end

    def test_val_3
      f = ''
      t = '1'
      assert( ! f.val? )
      assert( t.val? )
    end

  end

=end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
facets-1.0.3 packages/core/lib/facet/kernel/val.rb
facets-0.9.0 lib/nano/kernel/val.rb
facets-1.0.0 lib/facet/kernel/val.rb
facets-1.2.1 lib/facets/core/kernel/val.rb
facets-1.1.0 lib/facet/kernel/val.rb
facets-1.2.0 lib/facets/core/kernel/val.rb
facets-1.3.0 lib/facets/core/kernel/val.rb
facets-1.3.1 lib/facets/core/kernel/val.rb
facets-1.3.3 lib/facets/core/kernel/val.rb
facets-1.3.2 lib/facets/core/kernel/val.rb
facets-1.4.2 lib/facets/core/kernel/val.rb
facets-1.4.1 lib/facets/core/kernel/val.rb
facets-1.4.0 lib/facets/core/kernel/val.rb
facets-1.4.3 lib/facets/core/kernel/val.rb
facets-1.4.4 lib/facets/core/kernel/val.rb
facets-1.4.5 lib/facets/core/kernel/val.rb
facets-1.7.0 lib/facets/core/kernel/val.rb
facets-1.7.38 lib/facets/core/kernel/val.rb
facets-1.7.30 lib/facets/core/kernel/val.rb
facets-1.7.46 lib/facets/core/kernel/val.rb