Sha256: 255dea89be9ad7e4562d03c3d45f18aedb3a0a0f39529fb63fd4760ed3271a35

Contents?: true

Size: 430 Bytes

Versions: 5

Compression:

Stored size: 430 Bytes

Contents

require 'ganymed/websocket'

module Ganymed
  class Websocket
    class Filter
      def initialize(spec)
        @spec = spec
      end

      def match?(event)
        @spec.map do |skey, svalue|
          evalue = event.send(skey.to_sym)
          case svalue
          when String
            svalue == evalue
          when Array
            svalue.include?(evalue)
          end
        end.all?
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ganymed-0.2.1 lib/ganymed/websocket/filter.rb
ganymed-0.2.0 lib/ganymed/websocket/filter.rb
ganymed-0.1.2 lib/ganymed/websocket/filter.rb
ganymed-0.1.1 lib/ganymed/websocket/filter.rb
ganymed-0.1.0 lib/ganymed/websocket/filter.rb