Ruby Basics Flashcards
abstraction
Abstraction ensures that as users, we’re far removed from what’s happening “under the hood”
abstraction of ruby
Ruby is written in C, which translates to Assembly Language, which translates to machine language to translate 0s and 1s into something the computer understands.
Domain Specific Languages (DSL’s)
is a computer language specialized to a particular application domain. A higher level language based on a lower level. Rails or Rspec written in Ruby.
tab function
set to 2 spaces and indenting should be set to use spaces
sign
means anything after it, on the same line, is a comment
snake_case
When you define or initialize a method, variable, or file.
# Naming a file this_is_a_snake_cased_file.rb
# Assigning a variable forty_two = 42
# Defining a method def this_is_a_great_method # do stuff end
constant
When you want to represent a value that will not change in your Ruby program, you define a constant variable, often referred to as a constant. In Ruby, constants are denoted with all uppercase letters.
# Constant declaration FOUR = 'four' FIVE = 5
do/end blocks, prefer { }
when the entire code expression fits on one line.
# Multi-line [1, 2, 3].each do |i| # do stuff end
# Does the same thing in single line [1, 2, 3].each { |i| # do stuff }
CamelCase
naming your classes you will use CamelCase formatting. CamelCase uses no spaces and capitalizes every word.
# Class naming class MyFirstClass end
class MySecondClass end
API
API is an acronym for application programming interface, and is a somewhat overloaded term that can refer to both how applications talk to each other, as well as documentation. Just remember, if someone says “Did you take a look at the Array API?”, they’re talking about the Ruby docs documentation for the Array class. But if someone says “What’s the Twitter API?”, they’re talking about the programmatic interface to Twitter’s services.
mkdir
create a new directory
cd
change directory
touch
create a new file
rm
remove a file (delete)
cd ..
To navigate out of the current folder to the one above