Class: RI::MethodDescription

Inherits:
Object
  • Object
show all
Defined in:
lib/ihelp.rb

Instance Method Summary collapse

Instance Method Details

#to_html(container_tag = "div", header_tag = "h1") ⇒ Object

Creates HTML element from the MethodDescription. Uses container_tag as the root node name and header_tag as the tag for the header element that contains the method’s name.

Returns a REXML document with container_tag as the root element name.



487
488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'lib/ihelp.rb', line 487

def to_html(container_tag="div", header_tag="h1")
  doc = REXML::Document.new
  root = doc.add_element(container_tag)
  header = root.add_element(header_tag)
  header.add_text(full_name)
  comment.each{|c|
    tag = c.class.to_s.split("::").last
    tag = "PRE" if tag == "VERB"
    xmlstr = "<#{tag}>#{c.body}</#{tag}>"
    c_doc = REXML::Document.new(xmlstr)
    root.add_element( c_doc.root )
  }
  doc
end