1 / 9

IO and rdoc

IO and rdoc. File IO. File.new(filename, “r”) The mode may be r - read only w - write only r+ - read/write w+ - read/write; truncates file a - write/append a+ - read/append b - used with above modes, indicates binary mode. Using File. File.new nees a close

emele
Download Presentation

IO and rdoc

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IO and rdoc

  2. File IO • File.new(filename, “r”) • The mode may be • r - read only • w - write only • r+ - read/write • w+ - read/write; truncates file • a - write/append • a+ - read/append • b - used with above modes, indicates binary mode

  3. Using File • File.new nees a close • Make sure you put the close in ensure block to ensure it is closed • Alternately, you may use the open method • Open a file • You can work with it in the closure • closes automatically when you return from closure • safe since close is called in ensure

  4. Reading File • You may use gets or use one of the convenience methods • each_line by default uses \n as delimiter, you may specify some other character as well • IO.foreach may also be used

  5. Running all tests

  6. rdoc • Ruby documentation generator • like javadoc, ndoc, … • Produces html and ri documentation • Picks up comments before interesting elements like classes, methods,… • Picks up comments in # or between =being rdoc and =end • Comments between #-- and #++ are ignored • -word- or <em> multi words</em> for italics • *word* or <b> multi words</b> for bold • +word+ or <tt> multi words</tt> for typewriter

  7. rdoc presentation • Hyperlinks • Picks up as links the Class names, method names, elements preceded by #,… • http, www, … • Lists created using * or 1. or a. • =, ==, … for headings • --- for hr • Doc modifiers control what gets generated • :yield:, :nodoc:, :doc:, :notnew:, :call-seq:, :include:, … • RDoc::usage is useful to pick up usage comments for programs

  8. rdoc example

  9. rdoc output

More Related