Ruby Learning Guide

0 What is Ruby

Learn a new programming language by knowing what it is. What is a thing, it is recommended to look at the original introduction.

An open source dynamic programming language that emphasizes simplicity and efficiency. Ruby’s syntax is elegant, natural to read and comfortable to write.

I’m going to throw Hello World first.

puts "Hello World!"
Copy the code

However, you still don’t know how the above line of code works in what environment and with what carrier.

Take it slow.

Installing Ruby is the first step. Installing Ruby is actually installing the Ruby interpreter. A Ruby interpreter is just a piece of software or program that runs Ruby code.

1 install Ruby

Methods to install Ruby

There are several tools available for installing Ruby on every popular platform:

  • Linux/UNIX platforms, you can use third-party tools (such as Rbenv or RVM) or use the package management system on your system.
  • MacOS platform, you can use third-party tools (such as Rbenv or RVM).
  • Windows platform, can use RubyInstaller.

It’s a bit of a hassle to install, but I recommend developing on Linux and macOS, even though you can install it on Windows.

Is there a relatively easy way to install, and I would say no, a simple way just to hide the complexity of things themselves. I recommend installing based on RbenV. This is the ultimate Ruby installation solution.

2 Basic Introduction

Installation is painful, and some courses try to reduce the painful process, which I feel is unnecessary. It’s irresponsible to make it easy for you to learn a programming language in the first place.

How to prove that you have Ruby installed.

➜  ~ which ruby
/Users/gaoshuaipeng/.rbenv/shims/ruby
Copy the code

The Ruby version

➜  ~ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin18]
Copy the code

Of course your version may not be 2.3.1, it doesn’t matter. It’s the ability to install that matters.

3. Plan your learning roadmap

At this point, you still shouldn’t try any programs, or you might fall into the trap of local optimality, and you might end up tired.

First, think about where you came from and what you intend to learn Ruby for.

If you are going to learn some Ruby to do ai, I suggest you give up Ruby, Python is probably a better choice.

If you are going to learn a little Ruby to do front-end development, I suggest you abandon Ruby, JS is probably a better choice.

If you want to learn Ruby to do back-end development, you can try Ruby, but that’s just the beginning, and then you need to learn a Ruby-based back-end Web development framework, such as Rails. Of course you can try Python, of course that’s a different roadmap.

Have a goal, or it will be easy to learn without a goal.

Probably the most common use of Ruby is for back-end development. It is easy to do things when you think clearly.

Learn basic grammar

The basic syntax of a language is a very abstract concept. Programming skills are mostly learned by case study. The case study method is not important to learn the case, the important thing is to be able to draw inferences. Basic grammar is mostly tangible stuff.

  • The basic type of data
  • Control statement (conditional judgment, loop)
  • A representation of data in a collection class
  • Objects, variables, and constants
  • methods
  • class
  • The operator
  • Error handling and exceptions

Learn the Ruby feature language

  • The module
  • block

Learn the main classes

  • Numerical class
  • An array of class
  • String class
  • Hash class
  • Regular expression class
  • IO class
  • File and Dir classes
  • Encoding class
  • Time class and Date class
  • Proc class

Learn core libraries and standard libraries

  • ruby-doc.org/core-2.6.4/
  • Ruby-doc.org/stdlib-2.6….

Learn about third-party libraries

  • redis
  • mysql2
  • mongoid
  • sqlite3
  • rails
  • .

9. Learn some surroundings

  • Rails
  • Sinatra
  • Rack
  • Redis
  • MongoDB
  • MySQL
  • Linux
  • .