Class: IRuby::Message
- Inherits:
-
Object
show all
- Defined in:
- lib/iruby/message.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(msg_dict) ⇒ Message
A Message can be created from a dict and a dict from a Message instance simply by calling dict(msg_obj).“”“
8
9
10
11
12
13
14
15
16
|
# File 'lib/iruby/message.rb', line 8
def initialize msg_dict
@dct = {}
msg_dict.each_pair do |k, v|
if v.is_a?(Hash)
v = Message.new(v)
end
@dct[k] = v
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
18
19
20
|
# File 'lib/iruby/message.rb', line 18
def method_missing(m, *args, &block)
@dct[m.to_s]
end
|
Class Method Details
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/iruby/message.rb', line 30
def self.()
if .nil?
return {}
end
h = ['header']
h ||=
return h
end
|
22
23
24
25
26
27
28
|
# File 'lib/iruby/message.rb', line 22
def self.(msg_id, username, session)
return {
msg_id: msg_id,
username: username,
session: session
}
end
|