Sha256: 718680f0b275cc9d41c777aaa7d0565622ce6392d0a41a8ad0ce66a6bfe1c0b1
Contents?: true
Size: 908 Bytes
Versions: 65
Compression:
Stored size: 908 Bytes
Contents
require 'fsr/listener/inbound' module FSR module Listener module Inbound class Event def self.from(data) instance = new capture = header = {} body = {} data.each_line do |line| line.strip! case line when '' capture = body when /([a-zA-Z0-9-]+):\s*(.*)/ #capture[$1] = $2.strip key, val = line.split(":") capture[key] = val.to_s.strip end end instance.header.merge!(header) instance.body.merge!(body) instance end attr_reader :header, :body def initialize(header = {}, body = {}) @header, @body = header, body end def [](key) @header.merge(@body)[key] end end end end end
Version data entries
65 entries across 65 versions & 3 rubygems