Back End Lesson 2.2: Methods, Classes, Blocks

Welcome to Lesson 4 of the Ruby on Rails Backend Class. In this unit, we will learn:

  • Ruby blocks | Ruby classes | Block arguments | Yield
  • Object oriented programming | Loops
  • Modules | Methods | Class methods | Include and extend | Magic methods in Ruby

Back End Lesson 2.2 Goals

  • Learn what blocks are, different ways they can be called, and how to pass arguments to a block
  • Practice with Ruby methods
  • Practice with Ruby Classes, and creating your own classes
  • Implement methods with blocks
  • Blocks practice

Curriculum

This is your curriculum for Lesson 2.2.
**2.2.1 Ruby Blocks (96 min) 2.2.2 Build an Address Book in Ruby (109 min) 2.2.3 Ruby Modules (125 min)

Assignments

Your assignment for Lesson 2.2 can be found here

Your mindset assignment can be found here.

Cheatsheet

This is a very brief introduction to Ruby. You will do additional Ruby coding in lesson 2.3. However, we have covered all of the elements. It is not easy to learn an entire language this fast, but we need to continue so that we can adequately cover Rails. Please review this cheatsheet for Ruby, and make sure that you understand each of the elements of the cheatsheet: Cheatsheet.

Often you will need to refer to the classes and methods of the Ruby standard library. You can find a complete reference using Google. For example, suppose you need to understand the methods of the DateTime class. You can do a google search on ruby datetime and it will show you a reference. Here is a complete reference: https://ruby-doc.org/stdlib-3.0.2/

Rails expands the standard library. With Rails you get access to some classes and methods that aren’t in the Ruby base.

This site needs some love. Come contribute; we're open to contributors! Come lend a hand!