First, in ruby1.8, class variables are shared by all subclasses and parent classes, and you can look at the following code:
class IntelligentLife @@home_planet = nil def self.home_planet @@home_planet end def self.home_planet=(x)
ROR Official website:http://www.rubyonrails.org/As a starting point for understanding the technology, there's a 15-minute video that builds a blog that's worth a visit.Rolling with Ruby on
After using the rails new appname to build rails applications, we can view the directory structure of Rails applications through tree:
Directory structure
The application directory will have 11 directories of App, config, DB, Doc, lib, log, public,
Open Class
You can reopen a class that already exists and modify it dynamically, even if the class of a standard library like string or array is no exception. This behavior is called Open class
Monkey Patch
If you inadvertently add new
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
Installation
For Ubuntu, you need to install LIBXML2, libxslt these two components:
$ apt-get Install LIBXML2 libxslt
Then you can:
$ gem Install Nokogiri
Available optionsNokogiri provides some options for parsing
1. Establish an HTTP connection (send request parameters by Get method)
Require "Open-uri"
#如果有GET请求参数直接写在URI地址中
uri = ' Http://uri '
html_response = nil
open (URI) do |http|
Html_response = Http.read
end
puts Html_response
A collection of hashing-value pairs, similar to this: "Employee" => "salary". It is similar to an array, except that the index is the type of any object that passes through any key, not an integer index.
Sequential traversal of a hashing or value
Ruby arrays are ordered, any object's?? A collection of integer indices. The elements in each array are associated with an index mentioned.
The array subscript starts at 0, such as C or Java. The negative index assumes the end of the array---that
Git warehouse outputGit Archive--format=tar--prefix=actasfavor/head | (cd/home/holin/work/&& Tar XF-)Output to the/home/holin/work/actasfavor/directoryPosted by Holin at May 16, 2008 16:42Load controller and model in plugins# Include Hook code
Implementation of PRY,RONIN,MSF similar terminal under the interactive function, where the main use of RIPL gem:
1. Ability to invoke defined methods, such as Help2. Ability to execute system commands3. Ability to perform Ruby language parsing like
Recently there is a need to show the number as a fixed number of digits, the number of digits in the front with 0 supplements
Like 5-bit:
Copy Code code as follows:
3-> 00003
292-> 00292
12422-> 12422
It's easy to find Ruby.
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
Recently participated in the seven-cow demo contest, decided to use Ruby development. So I ran into some questions and then solved them, and here's a record.
In Ruby, Gem is a very common thing, it is the equivalent of Plug-ins, Ruby has a lot of
Cookies in Ruby, like other programming languages, have expires,domain,path,secure,name these references, so let's look at a simple cookie instance.
Cookies and sessions are stored as strings, and other types of data types are coerced into strings,
To raise this question is to have an objective attitude towards the way of thinking.For the programming language, I have always felt that those I have not used, listening to some of the cows have mentioned the language is better.I have been to
Ruby traverses the contents of the file, the basic idea is to read row by line printing, is also a more common method:#!/usr/bin/env ruby#encoding:utf8file = File.Open ("/tmp/abc.txt") file.each_line do |line| Print Lineendfile.closeAnother way of
Today is my first time to contact the Ruby language, according to the tutorial written a very simple Ruby program, the file named Hello.rb, the content is as follows:Puts "hello,ruby!";But the execution is error:After Baidu's solution is as follows:
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service