Sha256: 3cf4a243111e0829d044eee2134af9641d1aa3fd345b23595628229c7cbc5fca
Contents?: true
Size: 1.08 KB
Versions: 4
Compression:
Stored size: 1.08 KB
Contents
class FluQ::Event < Hash attr_reader :tag, :timestamp # @param [String] tag the event tag # @param [Integer] timestamp the UNIX timestamp # @param [Hash] record the attribute pairs def initialize(tag = "", timestamp = 0, record = {}) @tag, @timestamp = tag.to_s, timestamp.to_i super() update(record) if Hash === record end # @return [Time] UTC time def time @time ||= Time.at(timestamp).utc end # @return [Array] tuple def to_a [tag, timestamp, self] end # @return [Boolean] true if comparable def ==(other) case other when Array to_a == other else super end end alias :eql? :== # @return [String] tab-separated string def to_tsv [tag, timestamp, Oj.dump(self)].join("\t") end # @return [String] JSON encoded def to_json Oj.dump merge("=" => tag, "@" => timestamp) end # @return [String] mgspack encoded bytes def to_msgpack MessagePack.pack merge("=" => tag, "@" => timestamp) end # @return [String] inspection def inspect [tag, timestamp, Hash.new.update(self)].inspect end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
fluq-0.7.5 | lib/fluq/event.rb |
fluq-0.7.3 | lib/fluq/event.rb |
fluq-0.7.1 | lib/fluq/event.rb |
fluq-0.7.0 | lib/fluq/event.rb |