Class: AsyncapiCable::Runtime::StreamMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/asyncapi_cable/runtime/stream_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(template) ⇒ StreamMatcher

Returns a new instance of StreamMatcher.



4
5
6
7
# File 'lib/asyncapi_cable/runtime/stream_matcher.rb', line 4

def initialize(template)
  @template = template.to_s
  @regex = build_regex(@template)
end

Instance Method Details

#match?(stream) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
# File 'lib/asyncapi_cable/runtime/stream_matcher.rb', line 9

def match?(stream)
  return false if @regex.nil?
  !@regex.match(stream.to_s).nil?
end