Class: KyotoTycoon::Stream::Line
- Inherits:
-
Struct
- Object
- Struct
- KyotoTycoon::Stream::Line
- Defined in:
- lib/kyototycoon/stream.rb
Instance Attribute Summary collapse
-
#cmd ⇒ Object
Returns the value of attribute cmd.
-
#db ⇒ Object
Returns the value of attribute db.
-
#raw_args ⇒ Object
Returns the value of attribute raw_args.
-
#sid ⇒ Object
Returns the value of attribute sid.
-
#ts ⇒ Object
Returns the value of attribute ts.
Instance Method Summary collapse
Instance Attribute Details
#cmd ⇒ Object
Returns the value of attribute cmd
24 25 26 |
# File 'lib/kyototycoon/stream.rb', line 24 def cmd @cmd end |
#db ⇒ Object
Returns the value of attribute db
24 25 26 |
# File 'lib/kyototycoon/stream.rb', line 24 def db @db end |
#raw_args ⇒ Object
Returns the value of attribute raw_args
24 25 26 |
# File 'lib/kyototycoon/stream.rb', line 24 def raw_args @raw_args end |
#sid ⇒ Object
Returns the value of attribute sid
24 25 26 |
# File 'lib/kyototycoon/stream.rb', line 24 def sid @sid end |
#ts ⇒ Object
Returns the value of attribute ts
24 25 26 |
# File 'lib/kyototycoon/stream.rb', line 24 def ts @ts end |
Instance Method Details
#args ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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 ⇒ Object
39 40 41 42 43 |
# File 'lib/kyototycoon/stream.rb', line 39 def key @key ||= begin args.first || nil end end |
#time ⇒ Object
69 70 71 |
# File 'lib/kyototycoon/stream.rb', line 69 def time @time ||= Time.at(*[ts[0,10], ts[10, ts.length]].map(&:to_i)) end |
#value ⇒ Object
45 46 47 48 49 |
# File 'lib/kyototycoon/stream.rb', line 45 def value @value ||= begin args[1] || nil end end |
#xt ⇒ Object
51 52 53 54 55 |
# File 'lib/kyototycoon/stream.rb', line 51 def xt @xt ||= begin args[2] || nil end end |
#xt_time ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# 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 |