Class: Freeswitch::ESL::Protocol::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/freeswitch/esl/protocol/event.rb

Overview

Represents a FreeSWITCH event received in JSON format.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_json) ⇒ Event

Returns a new instance of Event.



12
13
14
# File 'lib/freeswitch/esl/protocol/event.rb', line 12

def initialize(raw_json)
  @data = JSON.parse(raw_json).freeze
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/freeswitch/esl/protocol/event.rb', line 10

def data
  @data
end

Instance Method Details

#[](key) ⇒ Object



16
17
18
# File 'lib/freeswitch/esl/protocol/event.rb', line 16

def [](key)
  data[key]
end

#bodyObject



36
37
38
# File 'lib/freeswitch/esl/protocol/event.rb', line 36

def body
  data["_body"]
end

#channel_variable(name) ⇒ Object



40
41
42
# File 'lib/freeswitch/esl/protocol/event.rb', line 40

def channel_variable(name)
  data["variable_#{name}"]
end

#job_uuidObject



32
33
34
# File 'lib/freeswitch/esl/protocol/event.rb', line 32

def job_uuid
  data["Job-UUID"]
end

#nameObject



20
21
22
# File 'lib/freeswitch/esl/protocol/event.rb', line 20

def name
  data["Event-Name"]
end

#subclassObject



24
25
26
# File 'lib/freeswitch/esl/protocol/event.rb', line 24

def subclass
  data["Event-Subclass"]
end

#uuidObject



28
29
30
# File 'lib/freeswitch/esl/protocol/event.rb', line 28

def uuid
  data["Unique-ID"]
end