module Slappy::Listener::Validatable

Attributes

pattern[RW]

Public Instance Methods

valid?(event) click to toggle source
# File lib/slappy/listeners/concerns/validatable.rb, line 8
def valid?(event)
  unless time_valid?(event)
    Debug.log 'Event happend in before start time'
    return false
  end

  target = event.send(target_element)
  unless target
    Debug.log 'Target is nil'
    return false
  end

  event.matches = target.match pattern
  unless event.matches
    Debug.log "Target is not match pattern(#{pattern})"
    return false
  end

  true
end

Private Instance Methods

time_valid?(event) click to toggle source
# File lib/slappy/listeners/concerns/validatable.rb, line 31
def time_valid?(event)
  return true if event.ts.nil?
  event.ts > Slappy.client.start_time
end