class Jubatus::Common::TTuple
Public Class Methods
new(*types)
click to toggle source
# File lib/jubatus/common/types.rb, line 164 def initialize(*types) @types = types end
Public Instance Methods
check_tuple(m)
click to toggle source
# File lib/jubatus/common/types.rb, line 168 def check_tuple(m) Jubatus::Common.check_type(m, Array) if m.size != @types.size raise TypeError, "size of tuple is %d, but %d is expected: %s" % [m.size, @types.size, m.to_s] end end
from_msgpack(m)
click to toggle source
# File lib/jubatus/common/types.rb, line 175 def from_msgpack(m) check_tuple(m) tpl = [] @types.zip(m).each do |type, x| tpl << type.from_msgpack(x) end return tpl end
to_msgpack(m)
click to toggle source
# File lib/jubatus/common/types.rb, line 184 def to_msgpack(m) check_tuple(m) tpl = [] @types.zip(m).each do |type, x| tpl << type.to_msgpack(x) end return tpl end