Class: Zircon::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/ircmad/zircon_ext.rb

Instance Method Summary collapse

Instance Method Details

#paramsObject

temporary monkey patch



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ircmad/zircon_ext.rb', line 15

def params
  @params ||= begin
    params = []
    case
    when !@rest[0].empty?
      middle, trailer, = *@rest
      params = middle.split(" ")
    when !@rest[2].nil? && !@rest[2].empty?
      middle, trailer, = *@rest[2, 2]
      params = middle.split(" ")
    when @rest[1]
      trailer = @rest[1]
    when @rest[3]
      trailer = @rest[3]
    end
    params << trailer if trailer
    params
  end
end

#to_jsonObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/ircmad/zircon_ext.rb', line 3

def to_json
  fencoding = -> s { s.respond_to?(:force_encoding) ? s.force_encoding('UTF-8') : s }
  {
    from: fencoding.call(from),
    to: fencoding.call(to),
    body: fencoding.call(body),
    type: fencoding.call(type),
    raw: fencoding.call(raw)
  }.to_json
end