YUKI Hiroshi
null+****@clear*****
Mon May 26 17:29:10 JST 2014
YUKI Hiroshi 2014-05-26 17:29:10 +0900 (Mon, 26 May 2014) New Revision: 317b31bf4550775b36a8e9b0daf0b81a4441059b https://github.com/droonga/droonga-message-pack-packer-ruby/commit/317b31bf4550775b36a8e9b0daf0b81a4441059b Message: Support *GeoPoint types Added files: lib/droonga/message-pack-packer/geo-point-formatter.rb Modified files: lib/droonga/message-pack-packer.rb Modified: lib/droonga/message-pack-packer.rb (+7 -1) =================================================================== --- lib/droonga/message-pack-packer.rb 2014-04-10 16:48:31 +0900 (b827eb1) +++ lib/droonga/message-pack-packer.rb 2014-05-26 17:29:10 +0900 (4882470) @@ -16,6 +16,7 @@ require "msgpack" require "droonga/message-pack-packer/time-formatter" +require "droonga/message-pack-packer/geo-point-formatter" module Droonga class MessagePackPacker @@ -49,7 +50,12 @@ module Droonga when Time @packer.write(TimeFormatter.format(object)) else - @packer.write(object) + case object.class.name + when "WGS84GeoPoint", "TokyoGeoPoint" + @packer.write(GeoPointFormatter.format(object)) + else + @packer.write(object) + end end end Added: lib/droonga/message-pack-packer/geo-point-formatter.rb (+35 -0) 100644 =================================================================== --- /dev/null +++ lib/droonga/message-pack-packer/geo-point-formatter.rb 2014-05-26 17:29:10 +0900 (345da92) @@ -0,0 +1,35 @@ +# Copyright (C) 2013-2014 Droonga Project +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1 as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +module Droonga + class MessagePackPacker + class GeoPointFormatter + class << self + def format(object) + formatter = new(object) + formatter.format + end + end + + def initialize(geo_point) + @geo_point = geo_point + end + + def format + @geo_point.to_s + end + end + end +end -------------- next part -------------- HTML����������������������������...下载