Class: RI::ClassDescription
Instance Method Summary collapse
-
#to_html(container_tag = "div", header_tag = "h1", methods_header_tag = "h2", methods_tag = "p") ⇒ Object
Creates HTML element from the ClassDescription.
- #to_text ⇒ Object
Instance Method Details
#to_html(container_tag = "div", header_tag = "h1", methods_header_tag = "h2", methods_tag = "p") ⇒ 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.
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 |
# File 'lib/ihelp.rb', line 871 def to_html(container_tag="div", header_tag="h1", methods_header_tag="h2", methods_tag="p") doc = REXML::Document.new root = doc.add_element(container_tag) header = root.add_element(header_tag) header.add_text(full_name) comment.each{|c| root.add_element( c.to_html.root ) } root.add_element(methods_header_tag).add_text("Class Methods") cmethods = root.add_element(methods_tag) class_methods[0...-1].each{|m| cmethods.add(m.to_html.root) cmethods.add_text(", ") } cmethods.add(class_methods.last.to_html.root) root.add_element(methods_header_tag).add_text("Instance Methods") imethods = root.add_element(methods_tag) instance_methods[0...-1].each{|m| imethods.add(m.to_html.root) imethods.add_text(", ") } imethods.add(instance_methods.last.to_html.root) doc end |
#to_text ⇒ Object
897 898 899 900 901 902 903 904 905 |
# File 'lib/ihelp.rb', line 897 def to_text segs = [full_name] segs += (comment || []).map{|c| c.to_text } segs << "" << "Class methods: " << (class_methods || []).map{|m| m.to_text }.join(", ") segs << "" << "Instance methods: " << (instance_methods || []).map{|m| m.to_text }.join(", ") segs << "" << "Constants: " << (constants || []).map{|m| m.to_text }.join("\n") segs << "" << "Attributes: " << (attributes || []).map{|m| m.to_text }.join("\n") segs.join("\n") end |