Method: Nori::CoreExt::Hash#to_xml_attributes

Defined in:
lib/nori/core_ext/hash.rb

#to_xml_attributesString

Returns The hash as attributes for an XML tag.

Examples:

{ :one => 1, "two"=>"TWO" }.to_xml_attributes
  #=> 'one="1" two="TWO"'

Returns:

  • (String)

    The hash as attributes for an XML tag.



28
29
30
31
32
# File 'lib/nori/core_ext/hash.rb', line 28

def to_xml_attributes
  map do |k, v|
    %{#{k.to_s.snakecase.sub(/^(.{1,1})/) { |m| m.downcase }}="#{v}"}
  end.join(' ')
end