Metaprogramming is not a very new concept, usually metaprogramming is considered to be a program to generate the program, if from this point of view, then Lex and YACC and JAVACC should all be considered to have the concept of metaprogramming, in
Everything in Ruby is an object. Even a block of code is an Object! In Ruby, a code object is called a block of code. You can imagine a code block as a small program unit. They contain Ruby code and can be transferred to the method when they are
This article mainly introduces the circulation statement summary in Ruby, this article summarizes some commonly used in Ruby the cyclic syntax, the need friend may refer to the next
while (when ...) ) loop
While conditionStatement
First, the basic grammar1. Get the Nokogiri object directly as a string:
Html_doc = nokogiri::html ("mr. Belvedere Fan club ")
Xml_doc = Nokogiri::xml (" alf ")
Html_doc and Xml_doc here are Nokogiri files.
2. Nokogiri objects can
Chinese garbled solutioncmd can not be entered in Chinese
Change the CMD code page to 936:
CHCP 936
Ruby read Chinese force set to Utf-8
You can add a comment statement to a file # Encoding:utf-8,ruby will be loaded in UTF-8 format
A single exception uses the FAIL keyword only to catch an exception and throw it over and over again (because you are not failing here, but are accurate and intentionally throwing an exception).
Begin
fail ' Oops '
rescue => error
send message to object display
We can send a message directly to the object:
Ruby Code
Copy Code code as follows:
Class HelloWorld
def say (name)
Print "Hello,", name
End
End
HW = Helloworld.new
Hw.send (: Say, "world")
1. How to declare a subclass
Copy Code code as follows:
Class Treasure
So the property name,description in the thing class are treasure inherited
2. What are the parameters of the Initialize method passed into the parent class
Recently playing Ruby, good to say, very feeling; OpenSUSE 12.3 on an old machine and then using RVM to install Ruby, in fact, any good release package Ruby is better than using RVM installed Ruby, personally feel (defy).
Then, when you install
1, the definition of the array
The array in Ruby is a dynamic array, the stored data is not qualified type, the length of the array is dynamically extended according to the storage needs, so, in the data definition, only the simplest way to new an
JRuby 1.7.14 Released, this version is now available for download:
Http://www.jruby.org/download
The JRuby 1.7 is designed to be compatible with the Ruby 1.9.3 version, and the improvement record is as follows:
Solved 30 issues.
Fixed a
Focus on private and protected
Public
The default is public, the global can be accessed, this does not explain
Private
C + +, "private" means "private to this class", but Ruby is the "private to this instance".In C + +, for Class A, you can
Create class: Class is followed by the name, where the first letter of the class name must be capitalized. When instantiated, it is instantiated with the new method. There are constructors in C #, and constructors have the same name as the class. In
This article mainly describes how I have raised Ruby gem Contracts.ruby speed by 10 times times.
Contracts.ruby is used in my project to add code contracts (contracts) to Ruby. It seems to be the same:
Contract num, num => num
def add (A, b)
When we are writing a module, it is more or less necessary to run the file directly or execute some methods, but this is not good for when the module is require or include, in Ruby, is there any distinction between running from the current file or
Before we tested model and controller, we learned some common test methods, and now we're going to delve into a few topics about testing. The first is to use a mock object.
In many cases, our program and the actual environment have dependencies,
In the last content, we realized the format of emptying the shopping cart and the amount. The module that implements the order this time.
1. First, we create the order table in the database, and create the SQL of the table as follows:
CREATE
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.