• Complain

Clements - Ruby Quick Syntax Reference

Here you can read online Clements - Ruby Quick Syntax Reference full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. City: Berkeley;CA;New York, year: 2014, publisher: Apress L.P, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Clements Ruby Quick Syntax Reference
  • Book:
    Ruby Quick Syntax Reference
  • Author:
  • Publisher:
    Apress L.P
  • Genre:
  • Year:
    2014
  • City:
    Berkeley;CA;New York
  • Rating:
    3 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 60
    • 1
    • 2
    • 3
    • 4
    • 5

Ruby Quick Syntax Reference: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Ruby Quick Syntax Reference" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Annotation

Ruby Quick Syntax Reference — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Ruby Quick Syntax Reference" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Matt Clements 2014
Matt Clements Ruby Quick Syntax Reference 10.1007/978-1-4302-6569-6_1
1. Introducing Ruby
Matt Clements 1
(1)
Bucks, UK
Ruby is a dynamic, object-oriented, programming language with an expressive syntax. It takes inspiration from several languages such as Smalltalk , Lisp , and Perl , adding features that make it very pleasant to program with. In recent years, Ruby exploded in popularity mainly thanks to the success of web development frameworks such as Ruby on Rails and Sinatra . However, it is also used with success in many other different contexts such as computer security ( Metasploit ), voice communications (A dhearsion ), and server configuration ( Opscode Chef and Puppet ), to name just a few.
Installing Ruby
In this book, we use the latest stable version available, which is, at the time of writing, the 2.0.0-p247 . If you are using a Linux distribution or Mac OS X, youll find a Ruby interpreter already installed. However, it might be an outdated version and usually it also has some limitations caused by the package manager on your operating system (for example, apt for Debian/Ubuntu linux distributions).
There are several ways to install the latest version of the Ruby interpreter, depending on the operating system you are using. If you already have this version installed, feel free to skip the following section.
Installing on Linux or Mac OS X
Even if Linux and Mac OS X are completely different operating systems, they both share the same UNIX philosophy and tools under the hood, so we have grouped them in the same section.
It is usually a good idea to install Ruby from source as this gives you more control over the installed version and, sometimes, lets you customize the installation. However, instead of manually downloading and compiling the Ruby source code, we are going to to use a tool called Ruby Version Manager (https://rvm.io) that helps you to easily install, manage, and work with multiple Ruby environments and interpreters. This means that, in theory, you can use several versions installed. Before you can install RVM and Ruby you need to install some dependencies. These can be development tools such as the compiler, or just external libraries like OpenSSL.
Linux Dependencies
On Debian/Ubuntu Linux, you can install these dependencies using the following command inside a terminal:
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config libgdbm-dev libffi-dev libreadline-dev
Some of the preceding packages are already installed because they are pretty common dependencies. This is not a problem; the apt tool manages this for you automatically.
If you are using another Linux distribution (Fedora/RedHat/CentOS, Arch Linux, etc.), dont worry, they all have a package management system that will help you install the dependencies.
Mac OS X Dependencies
On Mac OS X there isnt a default package manager; however, most people use Homebrew (http://brew.sh) and so do we. To do this, you need to have Xcode installed along with its command line tools. If you dont have Xcode installed, we suggest you install it from the Apple Mac App Store and install the command line tools in Xcode Preferences (Figure )
Figure 1-1 Command line tools Once Xcode and its command line tools are - photo 1
Figure 1-1.
Command line tools
Once Xcode and its command line tools are installed, you can proceed with the Homebrew installation. As we mentioned previously, Mac OS X ships with its default Ruby, we are going to use it to bootstrap Homebrew, which is written in Ruby too. Open Term.app and run the following command:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go )"
To check whether all the process went correctly, run:
brew doctor
This checks whether your system has all the tools and settings to run Homebrew properly. For example, you might be faced with this error:
Error: No such file or directory - /usr/local/Cellar
Dont worry, its just telling you that the default directory used by Homebrew to store all its stuff is missing. You can fix this with the following commands:
sudo mkdir /usr/local/Cellar
sudo chown -R `whoami` /usr/local
Setting Up RVM
Now that you have the tools for compiling and installing programs from source, you can finally install RVM. For now it doesnt matter if you are on Linux or Mac OS X, in both cases you have all the requirements. Run the following command inside your shell:
curl -L get.rvm.io | bash
This command installs and sets up RVM tools in your user directory, which means that RVM is available only for your current user and all the files are installed under your home directory. Once the installation is complete, you need two more steps. Run the following command to use RVM in the current shell:
source /.rvm/scripts/rvm
Add the following line to your /.profile to load RVM every time you open your terminal:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
As we have already seen for Homebrew, even RVM has a tool to check that all its requirements are met. Run the following command:
rvm requirements
If you have any missing required packages, you will need to install them before continuing by running brew install or apt-get install .
Installing Ruby 2.0.0
As stated before, RVM lets you install and use different Ruby versions on your system with ease. However, for our purposes, we are going to install only the latest stable available release. In your terminal, run the following command:
rvm install 2.0.0-p247
Now RVM downloads, compiles, and installs the specified version. Once it finishes, you need to set it as default Ruby interpreter and check that it works:
rvm use 2.0.0-p247 --default
ruby v
The output may vary depending on the operating system you are using; however it should look something like this:
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
Installing on Windows
On Windows things are bit different. Download the official installer on http://rubyinstaller.org/downloads/ , then run it and youre done.
A Quick Tour
Now we are ready for a quick tour of Ruby just to get your feet wet. Dont worry if something is not clear at first glance, the code snippets shown here are just for demonstration, each detail will be explained in later chapters of this book.
irb: The Interactive Ruby Shell
Before starting with examples, well introduce irb (short for interactive Ruby ), a Ruby shell. In other words, you type a Ruby expression at the irb prompt, and the expression will be evaluated and displayed. In this way, you can quickly try out small snippets without the need to edit a file and the run it. Open a terminal and run irb :
irb(main):001:0> 1 + 1
=> 2
irb(main):002:0> 'hello ' * 3
=> 'hello hello hello'
Type exit to close irb .
Object-Oriented
If you are not new to programming, you might have already heard of object-oriented languages such as Java or C#. However, Ruby is a bit different: it is completely object-oriented. In Ruby every value is an object , even numbers and booleans. In the following examples, you can see how a method is called on basic objects such as a numeric literal and a string. The # character indicates a comment (anything after it is not executed) and => is a commonly used convention to indicate the value returned by the commented code.
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Ruby Quick Syntax Reference»

Look at similar books to Ruby Quick Syntax Reference. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Ruby Quick Syntax Reference»

Discussion, reviews of the book Ruby Quick Syntax Reference and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.