T-12 to HW Due

  • Ruby Bits 1
    • Level 3
      • super can be used within a method inside a class to call a method with the same name in a parent class, if super is called without arguments it will automatically pass the arguments passed to the method that it lies in, to the parent’s method it references
      • rather than having a bunch of methods in one class and using case blocks to differentiate which methods should be called, your code will be faster if you separate the methods into many classes, that may inherit from one another, and just differentiate your objects with classes
  • Ruby Testing – Cooper Chapter 8
    • If you’d like to compare speeds of different coding strategies, you can show cpu time, you can make a measure object with the Benchmark class: a = Benchmark.measure do and then have your line of code. Even prettier, you can use the Benchmark.bm method, and in its do loop, make object.report("name_here") do blocks, which will generate prettier results (197)
      • There is also speed testing with Profiling, for which all you have to do is require 'profile' and call the methods, but it makes the code run much slower (198-199)
  • Ruby Gems – Cooper Chapter 7
    • The fact that I use rvm is apparently moot, since rvm manages to intercept all my normal Ruby installs. gem install works without sudo, and slowly. (174)
    • Use a gem in your code by doing require 'rubygems' ; require 'hpricot',
  • EventManager 0 – 3
    • The touch command creates a timestamp on a file
    • The curl command transfers a URL and the -o option writes an output file instead of stdout
    • You can read files by putting an object that is defined as: File.readlines or File.read. Alternatively using the CSV class, you may do CSV.open
    • The code below A second way to solve this problem is for us to track the index of the current line doesn’t work, printing row_index after incrementing it shows that it is not being incremented
    • It’s best to deal with a uniform set of values, so instead of checking for a nil in a method that manipulates strings, it would be better to have a special case for nil earlier, where it is converted to a string
  • Random
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s