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 |
# File 'lib/saml2/localized_name.rb', line 10 def initialize(element, name = nil) @element = element unless name.nil? if name.is_a?(Hash) replace(name) else self[nil] = name end 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
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/saml2/localized_name.rb', line 26 def [](lang) case lang when :all self when nil !empty? && first.last else super(lang.to_sym) end end |
#build(builder) ⇒ Object
50 51 52 53 54 |
# File 'lib/saml2/localized_name.rb', line 50 def build(builder) each do |lang, value| builder['md'].__send__(element, value, 'xml:lang' => lang) end end |
#from_xml(nodes) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/saml2/localized_name.rb', line 42 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.
38 39 40 |
# File 'lib/saml2/localized_name.rb', line 38 def to_s self[nil].to_s end |