Sha256: fc9ea718725a0ce505214747581c44ea944a080752726b41a52c6272e1d69dac

Contents?: true

Size: 829 Bytes

Versions: 15

Compression:

Stored size: 829 Bytes

Contents

require 'singleton'

module H8
  # The class representing undefined in javascript. Singleton
  # Nota that H8::Undefined == false but is not FalseClass
  class UndefinedClass
    include Singleton

    def blank?
      true
    end

    def undefined?
      true
    end

    def empty?
      true
    end

    def present?
      false
    end

    def !
      true
    end

    def == x
      x.is_a?(H8::UndefinedClass) || x == false
    end

  end

  # The constant representing 'undefined' value in Javascript
  # The proper use is to compare returned value res == H8::Undefined
  Undefined = UndefinedClass.instance

  # Convert javascript 'arguments' object to ruby array
  def arguments_to_a args
    res = Array.new(l=args.length)
    l.times { |n| res[n] = args[n] }
    res
  end

  module_function :arguments_to_a
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
h8-0.4.11 lib/h8/tools.rb
h8-0.4.10 lib/h8/tools.rb
h8-0.4.8 lib/h8/tools.rb
h8-0.4.5 lib/h8/tools.rb
h8-0.4.0 lib/h8/tools.rb
h8-0.3.0 lib/h8/tools.rb
h8-0.2.5 lib/h8/tools.rb
h8-0.2.4 lib/h8/tools.rb
h8-0.2.3 lib/h8/tools.rb
h8-0.2.2 lib/h8/tools.rb
h8-0.2.1 lib/h8/tools.rb
h8-0.1.4 lib/h8/tools.rb
h8-0.1.3 lib/h8/tools.rb
h8-0.1.2 lib/h8/tools.rb
h8-0.1.1 lib/h8/tools.rb