| Class | RI::ClassDescription |
| In: |
lib/ihelp.rb
|
| Parent: | Object |
Creates HTML element from the ClassDescription. Uses container_tag as the root node name and header_tag as the tag for the header element that contains the classes name. Uses methods_header_tag as the tag for the "Class/Instance Methods" method list headers. Uses methods_tag as the tag for the method lists.
Returns a REXML document with container_tag as the root element name.
# File lib/ihelp.rb, line 874
874: def to_html(container_tag="div", header_tag="h1",
875: methods_header_tag="h2", methods_tag="p")
876: doc = REXML::Document.new
877: root = doc.add_element(container_tag)
878: header = root.add_element(header_tag)
879: header.add_text(full_name)
880: comment.each{|c|
881: root.add_element( c.to_html.root )
882: }
883: root.add_element(methods_header_tag).add_text("Class Methods")
884: cmethods = root.add_element(methods_tag)
885: class_methods[0...-1].each{|m|
886: cmethods.add(m.to_html.root)
887: cmethods.add_text(", ")
888: }
889: cmethods.add(class_methods.last.to_html.root)
890: root.add_element(methods_header_tag).add_text("Instance Methods")
891: imethods = root.add_element(methods_tag)
892: instance_methods[0...-1].each{|m|
893: imethods.add(m.to_html.root)
894: imethods.add_text(", ")
895: }
896: imethods.add(instance_methods.last.to_html.root)
897: doc
898: end
# File lib/ihelp.rb, line 900
900: def to_text
901: segs = [full_name]
902: segs += (comment || []).map{|c| c.to_text }
903: segs << "" << "Class methods: " << (class_methods || []).map{|m| m.to_text }.join(", ")
904: segs << "" << "Instance methods: " << (instance_methods || []).map{|m| m.to_text }.join(", ")
905: segs << "" << "Constants: " << (constants || []).map{|m| m.to_text }.join("\n")
906: segs << "" << "Attributes: " << (attributes || []).map{|m| m.to_text }.join("\n")
907: segs.join("\n")
908: end