Sha256: 7862d90aa98678b0e2aaf82bd562d14ffab190706e429ccdff0db319861e34d0

Contents?: true

Size: 726 Bytes

Versions: 1

Compression:

Stored size: 726 Bytes

Contents

module WildcardMatchers
  module Matchers
    def is_a(klass)
      klass
    end

    [ String, Integer, Float, Hash, Array ].each do |klass|
      module_eval %{
        def is_a_#{klass.to_s.downcase}
          #{klass.inspect}
        end
      }
    end

    def is_bool
      lambda {|bool| TrueClass === bool or FalseClass === bool }
    end

    def is_time
      lambda do |time|
        require "time"
        time.is_a?(Time) or (Time.parse(time) rescue false)
      end
    end

    def is_a_member_of(*args)
      lambda do |item|
        args.flatten.any? {|expected| expected === item }
      end
    end
  end
end

require "wildcard_matchers/matchers/hash_includes"
require "wildcard_matchers/matchers/is_uri"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wildcard_matchers-0.1.1 lib/wildcard_matchers/matchers.rb