Class: Rfid::ClientMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/rfid/client_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ ClientMessage

Returns a new instance of ClientMessage.



7
8
9
10
11
# File 'lib/rfid/client_message.rb', line 7

def initialize(body)
  @hash = parse(body)
  @event_name = @hash['event'] || 'default'
  @data = @hash['data'] || {}
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/rfid/client_message.rb', line 5

def data
  @data
end

#event_nameObject (readonly)

Returns the value of attribute event_name.



5
6
7
# File 'lib/rfid/client_message.rb', line 5

def event_name
  @event_name
end

Instance Method Details

#performObject



13
14
15
16
17
18
19
# File 'lib/rfid/client_message.rb', line 13

def perform
  case @event_name
    when 'system' then run @data['command']
    else
      return false
  end
end