Skip to content

Instantly share code, notes, and snippets.

View FaisalAl-Tameemi's full-sized avatar

Faisal Al-Tameemi FaisalAl-Tameemi

View GitHub Profile
require_relative('./vehicle')
class Car < Vehicle
attr_reader :wheels
def initialize(title, capacity, make_year, color, fuel_type, wheels)
# remember: calling `super` alone will use the same set of parameters
# being passed into the current initialize when calling the parent's initialize
super(title, capacity, make_year, color, fuel_type)
@wheels = wheels

Technical Interview Questions

In Ruby, when we create a class, we can define attribute accessor and attribute readers.

class Car

  attr_reader :model, :top_speed
 attr_accessor :current_speed
@FaisalAl-Tameemi
FaisalAl-Tameemi / 01_intro_data_structures.rb
Created June 30, 2016 23:32
Staff Learn To Code // Chapter #1 - The Basics
# NOTE:
# for basic data structures such as strings, boolean and integers,
# please have a look at week 1 day 2 lecture notes
####################################################################
# ARRAYS: lists of things
# an array of names
names = ["Faisal", "Sara", "Jane"]

Breakout Notes

Important Terms

  • Method signature: The name of the method and its parameter list

  • Method contract: Given some inputs, what are the side-effects of a method and what does it return

@FaisalAl-Tameemi
FaisalAl-Tameemi / javascript_prototypes_vs_ruby_oop.md
Last active June 7, 2016 03:22
JS Prototypal OOP vs. Ruby Classical OOP

JavaScript Prototypes

What's the difference between Ruby's classical OOP and Javascript's Prototypes?

A class in a formal classist language can be an object, but it’s a special kind of object with special properties and methods. It is responsible for creating new instances and for defining the behaviour of instances.

class SmartShoe
def mergesort(array)
if array.count <= 1
# Array of length 1 or less is always sorted
return array
end
# Apply "Divide & Conquer" strategy
# 1. Divide
mid = array.count / 2

ARGV in Ruby

What's ARGV?

ARGV is a convention in programming which refers to the “argument vector,” in basic terms a variable that contains the arguments / parameters passed to a program through the command line.

Typically an array with contains each argument in a certain position within the array. This may work differently in languages other than Ruby.

Example of ARGV

Topics covered

  • Review of Rails Scopes & Namespacing

     namespace :admin do
         resources :reviews, only: [:index]
     end
@FaisalAl-Tameemi
FaisalAl-Tameemi / car.rb
Created March 9, 2016 19:36
Classes review + Module example
require_relative('./car_methods')
class Car
attr_accessor :current_speed
def initialize(model, color)
@model = model
@color = color
@current_speed = 0
require_relative('./car')
bmw = BMW.new("M4")
begin
bmw.accelerate
bmw.accelerate
rescue => e
puts e
end