Class: QuickAndRuby::DistinguishedName
- Inherits:
-
Object
- Object
- QuickAndRuby::DistinguishedName
- Defined in:
- lib/quick_and_ruby/distinguished_name.rb
Defined Under Namespace
Classes: Attribute
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = []) ⇒ DistinguishedName
constructor
A new instance of DistinguishedName.
- #reverse ⇒ Object
- #size ⇒ Object (also: #length)
- #to_s ⇒ Object
Constructor Details
#initialize(attributes = []) ⇒ DistinguishedName
Returns a new instance of DistinguishedName.
7 8 9 |
# File 'lib/quick_and_ruby/distinguished_name.rb', line 7 def initialize(attributes = []) @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/quick_and_ruby/distinguished_name.rb', line 5 def attributes @attributes end |
Class Method Details
.from_string(dn_str) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/quick_and_ruby/distinguished_name.rb', line 24 def self.from_string(dn_str) attributes = dn_str.split(/(?<!\\),/).map do |dn_component| unless (match = /^([^=]+)=(.*)$/.match(dn_component.strip)) raise "#{dn_component} is not a valid DistinguishedName component" end Attribute.new(*match.captures) end new(attributes) end |
Instance Method Details
#reverse ⇒ Object
20 21 22 |
# File 'lib/quick_and_ruby/distinguished_name.rb', line 20 def reverse self.class.new(attributes.reverse) end |
#size ⇒ Object Also known as: length
15 16 17 |
# File 'lib/quick_and_ruby/distinguished_name.rb', line 15 def size @attributes.size end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/quick_and_ruby/distinguished_name.rb', line 11 def to_s attributes.map(&:to_s).join(',') end |