Module: ADAM6050::Handler

Included in:
Login, Read, Status, Write
Defined in:
lib/adam6050/handler.rb,
lib/adam6050/handler/read.rb,
lib/adam6050/handler/login.rb,
lib/adam6050/handler/write.rb,
lib/adam6050/handler/status.rb

Overview

Handlers are, for the most part, simple transformations that accept a state, an incomming message, a session and a sender and produce a new state as well as an optional reply. The only

Defined Under Namespace

Classes: Login, Read, Status, Write

Constant Summary collapse

MESSAGE_PREAMBLE =

Returns the first letters of the message that should be used when determining if the handler can handle it.

Returns:

  • (String)

    the first letters of the message that should be used when determining if the handler can handle it.

'$01'

Instance Method Summary collapse

Instance Method Details

#handles?(msg) ⇒ true, false

Parameters:

  • msg (String)

    the incomming message.

Returns:

  • (true)

    if the handler can handle the message.

  • (false)

    otherwise.



15
16
17
# File 'lib/adam6050/handler.rb', line 15

def handles?(msg)
  msg.start_with? self.class::MESSAGE_PREAMBLE
end

#validate?true

Returns if the handler requires the sender to be validated.

Returns:

  • (true)

    if the handler requires the sender to be validated.



20
21
22
# File 'lib/adam6050/handler.rb', line 20

def validate?
  true
end