Class: QuickAndRuby::DistinguishedName::Attribute
- Inherits:
-
Object
- Object
- QuickAndRuby::DistinguishedName::Attribute
- Defined in:
- lib/quick_and_ruby/distinguished_name/attribute.rb
Constant Summary collapse
- SPLIT_RE =
DC domainComponent CN commonName OU organizationalUnitName O organizationName STREET streetAddress L localityName ST stateOrProvinceName C countryName UID userid
/^(\w+)=((?:\\.|[^\\])+)$/.freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, value) ⇒ Attribute
constructor
A new instance of Attribute.
- #to_s(escaper: nil) ⇒ Object
Constructor Details
#initialize(name, value) ⇒ Attribute
Returns a new instance of Attribute.
20 21 22 23 |
# File 'lib/quick_and_ruby/distinguished_name/attribute.rb', line 20 def initialize(name, value) @name = name @value = value end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/quick_and_ruby/distinguished_name/attribute.rb', line 18 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
18 19 20 |
# File 'lib/quick_and_ruby/distinguished_name/attribute.rb', line 18 def value @value end |
Class Method Details
.from_s(part, unescaper: nil) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/quick_and_ruby/distinguished_name/attribute.rb', line 32 def self.from_s(part, unescaper: nil) unless (match = SPLIT_RE.match(part)) raise "Invalid DN part: '#{part}'" end key = match[1].strip value = match[2].strip unescaped_value = value unescaped_value = unescaper.call(unescaped_value) if unescaper new(key, unescaped_value) end |
Instance Method Details
#to_s(escaper: nil) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/quick_and_ruby/distinguished_name/attribute.rb', line 25 def to_s(escaper: nil) escaped_value = value escaped_value = escaper.call(escaped_value) if escaper "#{name}=#{escaped_value}" end |