Class: SAML2::LocalizedName

Inherits:
Hash
  • Object
show all
Defined in:
lib/saml2/localized_name.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element, name = nil) ⇒ LocalizedName

Returns a new instance of LocalizedName.



8
9
10
11
12
13
14
15
16
17
# File 'lib/saml2/localized_name.rb', line 8

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

#elementObject (readonly)

Returns the value of attribute element.



6
7
8
# File 'lib/saml2/localized_name.rb', line 6

def element
  @element
end

Instance Method Details

#[](lang) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/saml2/localized_name.rb', line 19

def [](lang)
  case lang
  when :all
    self
  when nil
    !empty? && first.last
  else
    super(lang.to_sym)
  end
end

#build(builder) ⇒ Object



42
43
44
45
46
# File 'lib/saml2/localized_name.rb', line 42

def build(builder)
  each do |lang, value|
    builder['md'].__send__(element, value, 'xml:lang' => lang)
  end
end

#from_xml(nodes) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/saml2/localized_name.rb', line 34

def from_xml(nodes)
  clear
  nodes.each do |node|
    self[node['xml:lang'].to_sym] = node.content && node.content.strip
  end
  self
end

#to_sObject



30
31
32
# File 'lib/saml2/localized_name.rb', line 30

def to_s
  self[nil].to_s
end