This article to share is the individual use Ruby to write the crawl page image code, very simple and practical, the need for small partners can refer to.
Some time ago to see a lot of people write the next sister script, I also write a
?
A running program often encounters unexpected problems. A file to read does not exist; When you want to save some data, the disk is full; The user may enter inappropriate data.
ruby> file = open ("Some_file")
ERR: (eval): 1:in ' open ': No such
Now let's analyze the code of some of the previous example programs Bache.
The following example appears in a simple Example section.
def fact (N)
If n = 0
1
Else
n * Fact (N-1)
End
End
print fact (argv[0].to_i), "\ n"
Because this is the first
The local database creates the order table.
Suggestions include the following fields, referring to the official API (HTTPS://PINGXX.COM/DOCUMENT/API):
Order_no:required
The merchant order number, suitable for each channel requirement for
Ruby annotationNote hides a row for the Ruby interpreter, or part of a line, or several rows. You can use the character (#) at the beginning of the line:
# I'm a note, please ignore me.
Alternatively, the annotation can follow the same
Use:: To refer to constants (including classes and modules) and constructors (such as Array () or nokogiri::html ()).Never use:: To invoke a method.
# bad
someclass::some_method
some_object::some_method
# good
One, string operation
string interpolation
1.#{}: Any legitimate Ruby code placed in #{} will be evaluated and replaced with an evaluation result inserted in the original location
2. Single and double quotation marks differ:
Double quotes allow
1. Quickly get matching values for regular expressions
Usually we use regular expressions, which are match first, and then we take the result, but sometimes we throw an exception, and look at the following example:
Copy Code code as follows:
I've been learning about rails, because learning Java is an introductory language. It's a bit of a bad fit. In particular, Ruby's hash. But it's just a matter of thinking it through. It's basically a key-value. There is no big problem with writing
1. Foreword
Whether you use Ruby for System management or web development with rails, you may experience recurring tasks that follow a certain period of time (1 hours, 2 days ...). ) to be triggered continuously. In Ruby, I think it's convenient to
Two days ago in the "blog Park" read an article "PHP Basic Course", introduced PHP, feel good. D-Kuala is learning Ruby, just as well as writing a "Ruby starter Tutorial." To illustrate, this article is suitable for programmers who have no access to
Relevance Consulting's Stuart Halloway recently wrote a series of blog posts about the "Ruby vs. Java Geek talk". The inspiration for this series comes from his recent experience with a zero-start, previously constrained Ruby project that has been
Tutorial Requirements
The following techniques and resources are required to learn this tutorial:
Database server
NetBeans IDE 6.0 with Ruby support
To create a sample database
This tutorial builds the relationship between the Rails model based
In the previous section, we demonstrated how to build a list of items, and this time we built a simple shopping cart based on the previous content.
1. First we want to create a table that holds customer shopping information:
Database scripts:
The most frequently run query on a database is to return a conforming result set based on a specified condition, and the query may be to return all the names ' Dave's order, or all the titles on a blog with rails, in many other frameworks and
Today your leader to find you, hope you can help him a little busy, he is now anxious to go to the meeting. What can I do for you? You're curious.
He said to you, the current database of your project has a user information table, which contains a
Many times we will find that the real production environment is not a lot of external network, only intranet environment, this time we need to install Ruby, we can not provide the Yum command to install online, this time we need to download the
This example will show you how to escape and un-escape a value to be encoded in a URI and within HTML.
Require 'cgi' # Escapename = "Ruby? " Value = "Yes" URL = "Http://example.com /? "+ CGI. Escape (name) + '=' + CGI. Escape (value) +" & Var = t" #
Source and discussion: http://www.blogjava.net/calvin/archive/2005/11/01/17678.html
Author: Jiangnan Baiyi
The policy-base class in modern c ++ design is the same as that of cpper;The dependency injection of spring-type IOC container is the same
E-books: rubybasics tutorial version 4.
This book is a well-recognized introductory tutorial on Ruby in Japan. Song benhong personally reviewed the school and recommended it in sequence. This book supports the new version of Ruby2.0, and also
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.