YUKI Piro Hiroshi
null+****@clear*****
Tue Mar 24 23:49:14 JST 2015
YUKI "Piro" Hiroshi 2015-03-24 23:49:14 +0900 (Tue, 24 Mar 2015) New Revision: 593f08ffabb99bbe85b8ffb02a3d70e9f69ac54b https://github.com/droonga/droonga-engine/commit/593f08ffabb99bbe85b8ffb02a3d70e9f69ac54b Message: Store node part of an Address as a NodeName Modified files: lib/droonga/address.rb Modified: lib/droonga/address.rb (+16 -23) =================================================================== --- lib/droonga/address.rb 2015-03-24 23:42:47 +0900 (eb61b55) +++ lib/droonga/address.rb 2015-03-24 23:49:14 +0900 (89e8f33) @@ -13,7 +13,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -require "socket" +require "droonga/node_name" module Droonga class Address @@ -33,33 +33,26 @@ module Droonga raise ArgumentError, message end end - - def valid?(string) - begin - parse(string) - true - rescue ArgumentError - false - end - end end - DEFAULT_HOST = Socket.gethostname - DEFAULT_HOST.force_encoding("US-ASCII") if DEFAULT_HOST.ascii_only? - DEFAULT_PORT = 10031 - DEFAULT_TAG = "droonga" - - attr_reader :host - attr_reader :port - attr_reader :tag attr_reader :name def initialize(components={}) - @host = components[:host] || DEFAULT_HOST - @port = components[:port] || DEFAULT_PORT - @tag = components[:tag] || DEFAULT_TAG + @node = NodeName.new(components) @name = components[:name] end + def host + @node.host + end + + def port + @node.port + end + + def tag + @node.tag + end + def to_s string = node string << ".#{@name}" if @name @@ -67,7 +60,7 @@ module Droonga end def to_a - [@host, @port, @tag, @name] + @node.to_a + [@name] end def ==(other) @@ -75,7 +68,7 @@ module Droonga end def node - "#{@host}:#{@port}/#{@tag}" + @node.to_s end end end -------------- next part -------------- HTML����������������������������... 下載