Method: Hash#to_xml_attributes

Defined in:
lib/extlib/hash.rb

#to_xml_attributesString Also known as: to_html_attributes

Returns The hash as attributes for an XML tag.

Examples:

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

Returns:

  • The hash as attributes for an XML tag.



195
196
197
198
199
# File 'lib/extlib/hash.rb', line 195

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