Ruby odds ends
This presentation is the property of its rightful owner.
Sponsored Links
1 / 7

Ruby Odds & Ends PowerPoint PPT Presentation


  • 62 Views
  • Uploaded on
  • Presentation posted in: General

CS 480/680 – Comparative Languages. Ruby Odds & Ends. I/O Shortcuts. ARGV ARGF – the input stream specified on the command line Handy for file-processing scripts. Proc Objects. class JukeboxButton < Button def initialize(label, &action) super(label) @action = action end

Download Presentation

Ruby Odds & Ends

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Ruby odds ends

CS 480/680 – Comparative Languages

Ruby Odds & Ends


I o shortcuts

I/O Shortcuts

  • ARGV

  • ARGF – the input stream specified on the command line

    • Handy for file-processing scripts

Odds & Ends


Proc objects

Proc Objects

class JukeboxButton < Button

def initialize(label, &action)

super(label)

@action = action

end

def buttonPressed

@action.call(self)

end

end

bStart = JukeboxButton.new("Start") { songList.start }

bPause = JukeboxButton.new("Pause") { songList.pause }

Odds & Ends


The debugger

The Debugger

  • ruby –r debug script.rb

    • List (l)

    • Display (disp)

    • Break (b & del)

    • Watchpoints (w)

    • Continue (c)

    • Backtrace (where)

    • Help !!!

Odds & Ends


The profiler

The Profiler

  • See profiler.rb

Odds & Ends


The standard library

The Standard Library

  • Included with ruby, but you need to use ‘require’ for each library module you want to use.

  • Class Date

  • Module Find – see clean

  • Class File

  • Module Parsedate

  • Class Tempfile

  • Library Timeout

Odds & Ends


Require english

Require “English”

$* $ARGV$" $LOADED_FEATURES

$? $CHILD_STATUS$& $MATCH

$< $DEFAULT_INPUT$. $NR

$> $DEFAULT_OUTPUT$, $OFS

$! $ERROR_INFO$\ $ORS

$@ $ERROR_POSITION$\ $OUTPUT_RECORD_SEPARATOR

$; $FIELD_SEPARATOR$, $OUTPUT_FIELD_SEPARATOR

$; $FS$$ $PID

$= $IGNORECASE$' $POSTMATCH

$. $INPUT_LINE_NUMBER$` $PREMATCH

$/ $INPUT_RECORD_SEPARATOR$$ $PROCESS_ID

$~ $LAST_MATCH_INFO$0 $PROGRAM_NAME

$+ $LAST_PAREN_MATCH$/ $RS

$_ $LAST_READ_LINE

Odds & Ends


  • Login