Class: Jubatus::Common::TEnum

Inherits:
Object
  • Object
show all
Defined in:
lib/jubatus/common/types.rb

Instance Method Summary collapse

Constructor Details

#initialize(values) ⇒ TEnum

Returns a new instance of TEnum.


225
226
227
# File 'lib/jubatus/common/types.rb', line 225

def initialize(values)
  @values = values
end

Instance Method Details

#from_msgpack(m) ⇒ Object


229
230
231
232
233
234
235
# File 'lib/jubatus/common/types.rb', line 229

def from_msgpack(m)
  Jubatus::Common.check_type(m, Integer)
  if not (@values.include?(m))
    raise ValueError
  end
  return m
end

#to_msgpack(m) ⇒ Object


237
238
239
240
241
242
243
# File 'lib/jubatus/common/types.rb', line 237

def to_msgpack(m)
  Jubatus::Common.check_type(m, Integer)
  if not (@values.inlcude?(m))
    raise ValueError
  end
  return m
end