Class: Object

Inherits:
BasicObject
Defined in:
lib/to_xml.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.xml_typeObject



4
5
6
# File 'lib/to_xml.rb', line 4

def self.xml_type
  name.gsub(/([a-z])([A-Z])/,'\1-\2').downcase
end

Instance Method Details

#to_xml(name = nil) ⇒ Object



10
11
12
# File 'lib/to_xml.rb', line 10

def to_xml( name = nil )
  name ? %{<#{name} type="#{xml_type}">#{self.to_s}</#{name}>} : self.to_s
end

#to_xml!(*args) ⇒ Object



13
14
15
# File 'lib/to_xml.rb', line 13

def to_xml!( *args )
  %{<?xml version="1.0" encoding="UTF-8"?>\n} + to_xml( *args )
end

#xml_typeObject



7
8
9
# File 'lib/to_xml.rb', line 7

def xml_type
  self.class.xml_type
end