Class: CosNaming::NameComponent
- Inherits:
-
Object
- Object
- CosNaming::NameComponent
- Defined in:
- lib/corba/svcs/ins/cos_naming.rb
Overview
add some useful methods to CosNaming::NameComponent
Class Method Summary collapse
-
.from_string(snc) ⇒ Object
convert stringified name back to NameComponent.
Instance Method Summary collapse
-
#to_key ⇒ Object
create key value for registering in context map.
-
#to_string ⇒ Object
convert NameComponent to stringified format according to spec.
Class Method Details
.from_string(snc) ⇒ Object
convert stringified name back to NameComponent
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/corba/svcs/ins/cos_naming.rb', line 37 def self.from_string(snc) raise CosNaming::NamingContext::InvalidName.new if snc.empty? esc_ = false id_ = '' off_ = 0 snc.size.times do |i| case snc[i, 1] when '\\' esc_ = !esc_ when '.' unless esc_ raise CosNaming::NamingContext::InvalidName.new if off_ > 0 id_ = snc[0, i].gsub(/\\(\.|\\)/, '\1') off_ = i + 1 end esc_ = false else esc_ = false end end kind_ = snc[off_, snc.size].gsub(/\\(\.|\\)/, '\1') self.new(id_, kind_) end |
Instance Method Details
#to_key ⇒ Object
create key value for registering in context map
23 24 25 |
# File 'lib/corba/svcs/ins/cos_naming.rb', line 23 def to_key "#{self.r_id}|#{self.kind}" end |
#to_string ⇒ Object
convert NameComponent to stringified format according to spec
28 29 30 31 32 33 34 |
# File 'lib/corba/svcs/ins/cos_naming.rb', line 28 def to_string s = '' s = self.r_id.gsub(/([\/\.\\])/, '\\\1') unless self.r_id.to_s.empty? s << '.' if s.empty? or !self.kind.to_s.empty? s << self.kind.gsub(/([\/\.\\])/, '\\\1') unless self.kind.to_s.empty? s end |