1 / 11

URails

URails. Meeting 002. Goals. Learn some Linux Running Linux from the command-line Finding help for the command-line Filesystem Installing from source (RVM) Learn some Ruby Go over basic syntax How to execute a Ruby file Practice!. Install Cygwin. Go to www.cygwin.com

kalil
Download Presentation

URails

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. URails Meeting 002

  2. Goals • Learn some Linux • Running Linux from the command-line • Finding help for the command-line • Filesystem • Installing from source (RVM) • Learn some Ruby • Go over basic syntax • How to execute a Ruby file • Practice!

  3. Install Cygwin • Go to www.cygwin.com • Download setup.exe • Install the following packages: • git, svn, ncurses, openssl, make, g++, gcc, readline, xorg-server, xinit

  4. Linux Commands • Basic Format: • <program> <parameters> -<options> • Analogous to writing a method • Examples • ls lists the files in a directory • ls –l lists the files vertically and shows permissions • cd <some_directory> “moves” you to a different directory • cd ../ moves you back a directory • Time to practice!

  5. Help For Linux Commands • How can you know what parameters a program takes? • Most programs have a --help option • gcc --help (gcc is a C compiler) • Most programs have a man page (man for manual) • man ls

  6. Linux Filesystem System User • Essentially two parts: • System Files • User Files

  7. Linux Filesystem (cont.) • / = root (system files) • ~ = user/home (user files) • ~/ is short for /home/<user_name> • If your username was joe, typing cd ~/ would take you to /home/joe/ • This division is nice because all files that need to be backed up are typically in your user folder. • User folder is similar to the My Documents folder on Windows • Practice with RVM!

  8. Install RVM (Ruby Version Manager) • Cygwin users: Talk to me after, find a friend • Go to RVM website (see URails website) • Why use RVM? • Ruby (and Rails) is fast-changing • Let’s say you build an Rails app using Rails 3.0 and Ruby 1.8.7. Rails 3.1 comes out! Ruby 1.9.2 comes out! You install them, start using all their features, then come back to your Rails 3.0 project. They aren’t compatible. What do you do? • Use RVM! It manages different versions of Ruby and Gems

  9. Text Editor and IDE’s • What IDE to use for Ruby/Rails? • If you’re hardcore (Not IDE’s, just Text Editors) • vi (also called vim) (steep learning curve, worth it) • emacs (slightly steep learning curve, probably worth it) • Less hardcore • nano (simple linux text editor, smaller learning curve but less features) • gedit (nice middle ground of simple text editing and some advanced features) • NotePad/WordPad (No text highlighting) • Something more like Eclipse • Eclipse works, takes some setting up, never done it • RubyMine, probably good but costs money • My recommendation: • Don’t use a fancy IDE, it’s very worth it to get practice in an environment without auto-complete/auto-compilation warnings, etc. Rails is not an environment where there’s a lot to gain using an IDE. • Feel free to google “Rails IDE” for other options, I’ve only used vi

  10. Scripting vs Programming • What’s the difference? • Not a lot (in my opinion) • Scripting languages can be considered “lightweight” programming languages • Usually interpreted, not compiled • Usually looser syntax requirements • “Details” taken care of for you • Garbage Collection (Java has this too) • Dynamic Typing (no need to declare variable types) • Programming: intx = 5; • Scripting: x = 5

  11. Practice • Create a class called Fraction with the following methods: • Constructor that takes two numbers • Accessors and mutators for numerator and denominator (as well as instance variables) • to_s method (toString) • to_f method (toFloat) • simplify (optional) • Create a script that does the following • Creates an array • Stores 3 Fraction objects in the array • Permutes the objects in the array in a random order (there’s a single method for this, look at the Array documentation!) • Create a Hash with the same Fractions where the key is the fraction in english (i.e. if the fraction is 1/5, the symbol would be :one_fifth) • Print the contents of the Array to the console

More Related