Class: Droonga::Address
- Inherits:
-
Object
- Object
- Droonga::Address
- Defined in:
- lib/droonga/address.rb
Instance Attribute Summary collapse
-
#local_name ⇒ Object
readonly
Returns the value of attribute local_name.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #host ⇒ Object
-
#initialize(components = {}) ⇒ Address
constructor
A new instance of Address.
- #node ⇒ Object
- #port ⇒ Object
- #tag ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#local_name ⇒ Object (readonly)
Returns the value of attribute local_name.
38 39 40 |
# File 'lib/droonga/address.rb', line 38 def local_name @local_name end |
Class Method Details
.parse(string) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/droonga/address.rb', line 21 def parse(string) if /\A(.+):(\d+)\/([^.]+)(?:\.(.+))?\z/ =~ string components = { :host => $1, :port => $2.to_i, :tag => $3, :local_name => $4 } new(components) else format = "${host_name}:${port_number}/${tag}.${local_name}" = "volume address must be <#{format}> format: <#{string}>" raise ArgumentError, end end |
Instance Method Details
#==(other) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/droonga/address.rb', line 70 def ==(other) if other.is_a?(String) return to_s == other end other.is_a?(self.class) and to_a == other.to_a end |
#host ⇒ Object
44 45 46 |
# File 'lib/droonga/address.rb', line 44 def host @node_name.host end |
#node ⇒ Object
56 57 58 |
# File 'lib/droonga/address.rb', line 56 def node @node_name.node end |
#port ⇒ Object
48 49 50 |
# File 'lib/droonga/address.rb', line 48 def port @node_name.port end |
#tag ⇒ Object
52 53 54 |
# File 'lib/droonga/address.rb', line 52 def tag @node_name.tag end |
#to_a ⇒ Object
66 67 68 |
# File 'lib/droonga/address.rb', line 66 def to_a @node_name.to_a + [@local_name] end |
#to_s ⇒ Object
60 61 62 63 64 |
# File 'lib/droonga/address.rb', line 60 def to_s string = @node_name.node string << ".#{@local_name}" if @local_name string end |