Sha256: 35f16f794dad2216c9fc79dcc2c7116c58753c25af5e900007fea89a537af98c

Contents?: true

Size: 874 Bytes

Versions: 1

Compression:

Stored size: 874 Bytes

Contents

class Ircmad
  class Zircon::Message
    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

    # temporary monkey patch
    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ircmad-0.0.3 lib/ircmad/zircon_ext.rb