class SAML2::LocalizedName

Attributes

element[R]

Public Class Methods

new(element, name = nil) click to toggle source
Calls superclass method
# 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

Public Instance Methods

[](lang) click to toggle source

@param lang [String, Symbol, :all, nil]

The language to retrieve the localized string for.
+:all+ will return the hash itself, and +nil+ will return the first
localized string regardless of language.

@return [String]

Calls superclass method
# 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) click to toggle source
# 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) click to toggle source
# 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() click to toggle source

@return [String] The first localized string regardless of language

# File lib/saml2/localized_name.rb, line 39
def to_s
  self[nil].to_s
end