Class: SAML2::LocalizedName
- Inherits:
-
Hash
- Object
- Hash
- SAML2::LocalizedName
- Defined in:
- lib/saml2/localized_name.rb
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
Instance Method Summary collapse
- #[](lang) ⇒ String
- #build(builder) ⇒ Object
- #from_xml(nodes) ⇒ Object
-
#initialize(element, name = nil) ⇒ LocalizedName
constructor
A new instance of LocalizedName.
-
#to_s ⇒ String
The first localized string regardless of language.
Constructor Details
#initialize(element, name = nil) ⇒ LocalizedName
Returns a new instance of LocalizedName.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/saml2/localized_name.rb', line 10 def initialize(element, name = nil) super() @element = element return if name.nil? if name.is_a?(Hash) replace(name) else self[nil] = name end end |
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
8 9 10 |
# File 'lib/saml2/localized_name.rb', line 8 def element @element end |
Instance Method Details
#[](lang) ⇒ String
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/saml2/localized_name.rb', line 27 def [](lang) case lang when :all self when nil !empty? && first.last else super(lang.to_sym) end end |
#build(builder) ⇒ Object
51 52 53 54 55 |
# File 'lib/saml2/localized_name.rb', line 51 def build(builder) each do |lang, value| builder["md"].__send__(element, value, "xml:lang" => lang) end end |
#from_xml(nodes) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/saml2/localized_name.rb', line 43 def from_xml(nodes) clear nodes.each do |node| self[node["xml:lang"].to_sym] = node.content && node.content.strip end self end |
#to_s ⇒ String
Returns The first localized string regardless of language.
39 40 41 |
# File 'lib/saml2/localized_name.rb', line 39 def to_s self[nil].to_s end |