Class: Ritsudo::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/ritsudo/message.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ Message

Returns a new instance of Message.



14
15
16
# File 'lib/ritsudo/message.rb', line 14

def initialize(message)
  @message = message
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/ritsudo/message.rb', line 3

def message
  @message
end

Class Method Details

.wrap(raw_messages) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/ritsudo/message.rb', line 5

def self.wrap(raw_messages)
  messages = raw_messages.map { |raw|
    JSON.parse(raw.message)["message"]
  }.reject { |message|
    message["method"] == "Network.dataReceived" # don't use received info
  }
  messages.map { |message| Ritsudo::Message.new(message) }
end

Instance Method Details

#methodObject



18
19
20
# File 'lib/ritsudo/message.rb', line 18

def method
  message["method"]
end

#param(name) ⇒ Object



34
35
36
# File 'lib/ritsudo/message.rb', line 34

def param(name)
  params&.[](name)
end

#paramsObject



30
31
32
# File 'lib/ritsudo/message.rb', line 30

def params
  message["params"]
end

#timestampObject



22
23
24
# File 'lib/ritsudo/message.rb', line 22

def timestamp
  param('timestamp')
end

#urlObject



26
27
28
# File 'lib/ritsudo/message.rb', line 26

def url
  param("request")&.[]("url") || 'none'
end