class KyotoTycoon::Stream::Line

Public Instance Methods

args() click to toggle source
# File lib/kyototycoon/stream.rb, line 25
def args
  @args ||= begin
    return [] if raw_args.nil?
    k,v = *raw_args.split("\t").map{|v| v.unpack('m').first}
    return [k] unless v
    xt = 0
    v.unpack('C5').each{|num|
      xt = (xt << 8) +  num
    }
    v = v[5, v.length]
    [k, v, xt]
  end
end
key() click to toggle source
# File lib/kyototycoon/stream.rb, line 39
def key
  @key ||= begin
    args.first || nil
  end
end
time() click to toggle source
# File lib/kyototycoon/stream.rb, line 69
def time
  @time ||= Time.at(*[ts[0,10], ts[10, ts.length]].map(&:to_i))
end
value() click to toggle source
# File lib/kyototycoon/stream.rb, line 45
def value
  @value ||= begin
    args[1] || nil
  end
end
xt() click to toggle source
# File lib/kyototycoon/stream.rb, line 51
def xt
  @xt ||= begin
    args[2] || nil
  end
end
xt_time() click to toggle source
# File lib/kyototycoon/stream.rb, line 57
def xt_time
  @xt_time ||= begin
    if args[2]
      # if not set xt:
      # Time.at(1099511627775) # => 36812-02-20 09:36:15 +0900
      Time.at(args[2].to_i) 
    else
      Time.at(0)
    end
  end
end