Sha256: 54c99ed2d4df1590d72302e1468d7850ad77f09367ff5053972d4ea22bd93243

Contents?: true

Size: 924 Bytes

Versions: 8

Compression:

Stored size: 924 Bytes

Contents

module Erlectricity
  class Condition
    def self.for(a)
      case a
        when Condition then a
        when Class then TypeCondition.new(a)
        else StaticCondition.new(a)
      end
    end

    def initialize
    end

    def binding_for(arg)
      nil
    end

    def satisfies?(arg)
      false
    end

    alias === satisfies?
  end

  module Conditions
    def atom
      TypeCondition.new(Symbol)
    end

    def any
      TypeCondition.new(Object)
    end

    def number
      TypeCondition.new(Fixnum)
    end

    def pid
      TypeCondition.new(Erlectricity::Pid)
    end

    def ref
      TypeCondition.new(Erlectricity::NewReference)
    end

    def string
      TypeCondition.new(String)
    end

    def list
      TypeCondition.new(Array)
    end

    def hash
      HashCondition.new()
    end

    def boolean
      BooleanCondition.new()
    end
  end

  extend Conditions
end

Any = Object

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
mojombo-erlectricity-1.0.0 lib/erlectricity/condition.rb
mojombo-erlectricity-1.0.1 lib/erlectricity/condition.rb
mojombo-erlectricity-1.0.2 lib/erlectricity/condition.rb
erlectricity-funbox-1.1.2 lib/erlectricity/condition.rb
erlectricity-1.1.1 lib/erlectricity/condition.rb
erlectricity-1.1.0 lib/erlectricity/condition.rb
erlectricity-1.0.0 lib/erlectricity/condition.rb
erlectricity-1.0.1 lib/erlectricity/condition.rb