IO and rdoc - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

IO and rdoc

Description:

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 ... – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 10
Provided by: venkatsub
Learn more at: http://www2.cs.uh.edu
Category:
Tags: rdoc | truncates

less

Transcript and Presenter's Notes

Title: IO and rdoc


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 ltemgt multi wordslt/emgt for italics
  • word or ltbgt multi wordslt/bgt for bold
  • word or ltttgt multi wordslt/ttgt 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,
  • RDocusage is useful to pick up usage comments
    for programs

8
rdoc example
9
rdoc output
Write a Comment
User Comments (0)
About PowerShow.com