/ruby-notes

ruby essential training

Primary LanguageRuby

ruby-essential-training

My notes taken during course from kevin skoglund, lynda.com

# this is a single line comment

=begin
  this is a multi line comment
  IMPORTANT!!! the = must be the first character on the line
=end

# ruby devs prefer TWO space indentation not four, this is kinda important to the community

On the command line

$ irb                # start interpreter on command line
$ irb --simple-prompt
> quit               # quit to exit

$ ruby -v            # to get version / see if installed

$ ruby myscript.rb   # must include .rb extension to run a script

Docs are at http://ruby-doc.org/core

Also docs avail from command line just type ri before a command

$ ri upcase     # spits out docs for upcase same as at the link above 

-objects, vars, ints, floats, strings, string templates, arrays, hashes, symbols, booleans, logic operators, ranges, constants
ch2-obj-var-float-hash-symbol-etc.rb

-if, elsif, unless, case, ternary, or, or-equals
ch3.1-if-elsif-unless-case-ternary-or.rb

-loop, while, until, upto, each, for, in
ch3.2-loop-while-until-times-upto-each-for-in.rb
• Added additional research on block delimeters do end vs { } with a stack overflow question

-code block uses local variable instead of block scope variable in older versions of ruby
ch4.1-code-block-scope-ruby-1.9.1.rb

-find, include, find-all, any?, all?, delete-if
ch4.2-find-include-any-all-delete-if.rb
• Added additional research, code block as a transformer for the method

-merge and collect
ch4.3-merge-collect.rb

-comparison operator and sort
ch4.4-comparison-operator-sort.rb

-inject and memo
ch4.5-inject-memo.rb

-methods aka functions
ch5-methods-aka-functions-require-args-return.rb

-classes, instance scoped vars, attr, initialize method
ch6.1-classes-attr-instance-vars-initialize.rb
• Additional research, how do we set a private method when all methods are public by default?
• Stackoverflow thread explaining confusing part of the turoial where the method is named 'noise='

-class methods, example factory, class scoped vars, class scoped reader and writer
ch6.2-class-method-and-class-scope-reader-writer.rb
• TO DO: Additional research needed on keyword self. when used inside the initialize method, is it pointing to the instance not the class?

inheritance, subclass superclass, overriding methods, calling super
ch6.3-inheritance-subclass-superclass-override-super.rb

modules, namespacing, require and include
ch7-modules-namespacing-require-include.rb