Class: XRBP::WebSocket::Command

Inherits:
Message
  • Object
show all
Defined in:
lib/xrbp/websocket/command.rb

Instance Attribute Summary collapse

Attributes inherited from Message

#bl, #connection, #result, #time

Instance Method Summary collapse

Methods inherited from Message

#signal, #to_s, #wait

Constructor Details

#initialize(data) ⇒ Command

Returns a new instance of Command.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/xrbp/websocket/command.rb', line 7

def initialize(data)
  @@id ||= 0
  @id = (@@id += 1)

  json = Hash[data]
  json['id'] = id

  @json = json

  super(json.to_json)
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/xrbp/websocket/command.rb', line 4

def id
  @id
end

#jsonObject (readonly)

Returns the value of attribute json.



5
6
7
# File 'lib/xrbp/websocket/command.rb', line 5

def json
  @json
end

Instance Method Details

#requestingObject



19
20
21
# File 'lib/xrbp/websocket/command.rb', line 19

def requesting
  @json[:command] || @json["command"]
end

#requesting?(tgt) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/xrbp/websocket/command.rb', line 23

def requesting?(tgt)
  requesting.to_s == tgt.to_s
end