Ruby Intro/General Info (I) Flashcards

1
Q

Who created Ruby? When? What was the main idea behind it?

A

Yukihiro Matsumoto

Mid-1990s

“software should be understood by humans first and computers second”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Ruby on Rails is a framework. What is a framework?

A

SHORT ANSWER: a collection of libraries that make building web applications easier. they can automate common activities done in web development
(database access, session management, etc.)

LONG ANSWER: A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs.

These frameworks provide a standard way to build and deploy web applications on the World Wide Web. Web frameworks aim to automate the overhead associated with common activities performed in web development. For example, many web frameworks provide libraries for database access, templating frameworks, and session management, and they often promote code reuse.[1]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are three layers of abstraction with regard to a cell phone?
(think of three different people)

A

normal user = doesn’t care about what’s under the hood/just taps icons and makes calls/uses the phone’s interface

technician = must know how the phone’s components interact with the various sub-systems of the phone

programmer = must know all about the OS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

True or false?

Higher-level computer languages are just abstractions of lower-level ones.

A

True

STARTING HIGHER AND MOVING TO LOWER:

  • Ruby on Rails
  • Ruby
  • C
  • Assembly Language
  • Machine Language (binary/zeros and ones/something your computer’s CPU understands)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why is it a bad idea to try and learn Rails before you learn Ruby?

A

Because Rails is an abstraction of Ruby. If you don’t know how Ruby works, it will be that much harder for you to grasp Rails

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a code editor used for?

A

To create plain text documents with no styling or formatting

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In VS Code, how many spaces should your tab ident be set to?

A

two spaces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In VS Code, what is # used for?

A

a one-line comment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is snake case formatting? When do you use it?

What is camel case formatting? When do you use it?

When do you use all upper-case letters?

A

When you define or initialize a method, variable, or file
( my_variable = 6, def add_six(number), etc.)

When naming a class
(class MyFirstClass, etc.)

When you define a constant variable
(FIVE = 5, etc.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is another name for the Ruby documentation?

A

API

“Have you read the Array API?”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

In the Ruby docs, what do these symbols mean in the Methods menu?

: :

#

A

: : class methods

 instance methods
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the difference between class methods and instance methods?

A
class methods: are called directly to a class:
String.new("blue")
( b = String is the name of a class)

instance methods: are called to any instance of the class: “Hello”.split
(“Hello” is an instance/example of a string, and .split is an instance method)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

True or false?

In Ruby, every class (String, etc) sub-classes from some “parent”

A

True

For example, the parent of String is Object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

There are three places a class can draw methods from. What are they?

A

1-the instance and class methods in the “Methods” menu on the left side of the screen

2-the instance and class methods available to the parent class of the class you're reading about
(String has a parent called Object, and object has methods that String can use)

3-the instance and class methods available in the “Included Modules” menu

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is irb?

A

Ruby’s built-in interactive environment that lets you test code snippets and practice coding

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does an interpreter do?

A

it takes Ruby code and turns it into a language a computer can understand (machine language)

17
Q

This is a sample prompt in Ruby’s irb:

2.5.3p-247 :001 >

2.5.3p-247 = ?

:001> = ?

A

the version of ruby you’re using

the line you are on

18
Q

What does the command line let you do with ruby?

What does the irb let you do with ruby?

A

command line = lets you run ruby files that contain ruby code

irb = lets you run ruby commands/code snippets

19
Q

What are ruby gems?

A

pre-packaged bundles of code written by someone to solve a common problem

this means you won’t have to re-invent the wheel each time, so development speed will be increased

20
Q

What is pry?

A

a library that is especially useful for its code debugging capabilities