Ruby learning plan-(0) preface, ruby Preface
Preface
Currently, C, C ++, Java, Object-C, and Swift programming languages have been used. The most familiar language is oc. After all, it depends on him for dinner. It is only a beginner's path for other languages. Because he has been engaged in iPhone app development, recently, I wanted to develop a project by myself, but there was no backend, so I was so
Global variable $ XX
Object variable @ xx
Local variable [A-Z] xx
Constant [A-Z] xx
Two pseudo variables self and nil:Self is actually a global variable pointing to the current object. The value of this variable is controlled by the interpreter and can only be read and cannot be modified.Nil is also a global variable controlled by the interpreter and cannot be assigned a value.
1. Global variable $ XXGlobal variables should be used with caution because their scope is script-level and can
Because Ruby 1.9.3 uses psych to parse Yaml (unlike Ruby 1.8.7), Psych needs libyaml support.
First you need to update the relevant components:
Yum-y install make gcc openssl-devel zlib-devel gcc gcc-c++ make autoconf readline-devel curl-devel expat-devel Evel Ncurses-devel sqlite3-devel mysql-devel httpd-devel wget
1. Install Libyaml
$ wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
$ tar xzvf y
Tutorial on creating and using hash in Ruby and ruby hash
Hash is a set of key-value pairs similar to "employee" => "salary. Hash indexes are completed by any key of any object type, rather than an integer index. Others are similar to arrays.
The hash traversal order by key or value seems random, and is generally not in the insertion order. If you try to access the hash using a key that does not exist, the
An example is provided to explain the regular expressions in Ruby and the regular expressions in ruby.
A regular expression is a special character sequence that can help match or find other strings or strings. The pattern used maintains a special syntax.
The regular expression text is a slash between a pattern or any separator % r is as follows:Syntax:
Copy codeThe Code is as follows:/pattern//Pattern/im #
Ruby meta-programming summary, ruby Summary
When I was asked such questions today, I used to think that this is a broad concept. Even if I have used these features, but I still don't know this is called "metaprogramming" until today when I was asked, I just had an epiphany, and then I made a small summary on the Internet with some of my actual metaprogramming.
The so-called meta-programming in
For Ruby introduction, see: http://www.ruby-lang.org/zh_CN/about/
I. IRB
Interactive Ruby help and consoleProgramIn Windows.
You can directly execute Ruby in IRB.Code. For example:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
IRB (main ):
001
: 0
>
"
Hello World
"
=>
"
Hello W
Enter the command line in ruby to compile sass (ruby) and rubysass
Ruby(Or cmd) Enter the command line to compile sass as follows:
(1) For example: first, create a total folder under drive F, such as the test folder, and then create folders such as html, images, js, and sass under the folder.
(2) Create the sass file to be used in the sass folder. For example, co
I have always been very interested in Ruby on Rails. I want to see something that has been praised by many people, but I have been working on windows development, it is still a headache to build the development environment of Ruby on Rails, Which is why Ruby on rails has not been studied. I just saw InstantRails In javaeye, an All-In-One suite, which can help you
Brief explanation of the scope of Ruby Object-Oriented Programming and ruby Object-Oriented Programming
Scope
Ruby does not have nested scopes (internal scopes, which can be viewed as external scopes). Their scopes are completely separated. Once a new scope is entered, the original binding will be replaced with a new binding group.
The program will close the prev
Ruby captures web images and ruby captures images.
Some time ago, I saw a lot of scripts written by my sister, and I wrote one myself.
Module CommonHelper require 'nokogiri 'require 'open-uri 'def down_load_xmz site_url = "http://www.xxx.com" for index_page in 1 .. 141 doc_html = Nokogiri: HTML (open (site_url + '/share/comment-page-' + index_page.to_s) doc_html.css ("# comments p img "). each do | item_i
Ruby Web Real-Time Message backend server push technology --- GoEasy, ruby --- goeasy
More and more projects require real-time message pushing and receiving. How can we use Ruby to achieve the most convenient? We recommend that you use GoEasy, a third-party PUSH Service Platform. You can use its APIs to easily push messages in real time!
Browser compatibility: Go
Ruby concise learning notes (2): class inheritance, attributes, class variables, and ruby learning notes
1. How to declare a subclassCopy codeThe Code is as follows:Class Treasure In this way, the property names and descriptions of Thing classes are inherited by Treasure.
2. What are the parameters used to pass in the initialize method of the parent class in the following three methods?Copy codeThe Code is
Ruby Plus is a site offering free Ruby and rails related screencasts recorded by Bala paranj, much in the same vein as Ryan Bates 'railscasts. the screencasts are generally similar in length and overall format to those from railscasts. so far there are 29 episodes you can download. The first twelve screencasts in the archive (for which you have to register to download, alas) were exclusively
A summary of some common file operations in Ruby and a summary of ruby operations
A lot of Ruby beginners need to learn. Now we are trying to use Ruby to write a script. Many file-related operations are used, which are sorted in stages here. This facilitates subsequent searches.
Whether the file or directory exists
Collections writing guide in Ruby and Ruby collections writing guide
Preference array and the literal representation of Hash (unless you need to pass parameters to their constructor ).
# bad arr = Array.new hash = Hash.new # good arr = [] hash = {}
When you need an array with elements of words (no spaces or special characters), you always use % w to define a string array. Apply this rule to only two
Installation will not say, the official website has, but today released ruby2.3, so updateEnter the. Rbenv directory, perform a git pull update, but update rbenv, execute rbenv install-l and do not have the latest 2.3.0 release version.Then I looked at the git repository for the Ruby-build plugin, with 2.3 code. Suspect this also to be updated, so.Go to the. Rbenv/plugins/ruby-build directory and execute gi
Ruby parsing JSONRuby Parsing JSON Example:
JSON = ' ["A", "B", "C"] '
puts "Unsafe #{unsafe_json
(JSON). Inspect}"
#输出Unsafe
["A", "B", "C"]
Ruby parses JSON to parse the above JSON string into array. Such a method is not safe, for example:
JSON = ' puts ' Danger'll
Robinson '
puts ' Unsafe #{unsafe_json
(JSON). Inspect} "
And what should we export? Unfortunately, there is
GitHub advocates a summary of Ruby coding styles, while github advocates ruby code.
Source code layout: 1. All source files are UTF-8 encoded2. indent with two spaces3. Use Unix-style line breaks (\ n) and windows (\ r \ n ). You can use git config -- global core. autocrlf true to prevent the generation of windows-style line breaks.4. After ',', ';', add spaces before and after the operator (except for expo
Common Ruby file operation code instances and ruby code instances
# Create a 222. rb file and the input character File = file. open ("222.rb"," w + ") file. puts "123 \ nwadwa \ n12124124 \ ndwdw" file. close # output 222. rb content File. open ("222.rb"," r + ") do | file | while line = file. getsputs lineendend # directly use IO to operate the file IO. foreach ("222.rb") do | line | puts line if line = ~
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.