Classes and objects in Ruby are important knowledge points. To learn the Ruby language, you must first master the application of Ruby objects and classes. Here we will learn about the Ruby core class.
Ruby blocks provides flexible encoding methods
RubyGems is a convenient and powerful Ruby package manager, similar to the RedHat RPM. It packs a Ruby application into a gem and acts as an installation unit. Features: allows you to manage dependencies between Remote Installation Package packages.
The first browser version of Ruby 1.9.3 has been released. It is a reference version that may contain bugs, but these bugs will be fixed in the next version of Ruby 1.9.3-p0.
Improvements in this version since 1.9.2 include:
1. License change:
Life cycle:
Yukihiro Matsumoto was born on February 1, April 14, 1965 in Tokushima Prefecture, Japan. In 1984, he studied at the Department of Information, the third discipline of zhubo University. Two years later, I will be absent from school and
BKJIA exclusive Article] With the rapid development of computers, more and more programming languages have emerged. In the past 10 years, due to the speed of development, Java has become the leader in programming languages. As Java continues to
Object-orientedIt is a confusing wording. object orientation makes others think you are fashionable. ruby claims to be an object-oriented scripting language, but what exactly is "Object-Oriented "?We already have a variety of answers, but all these
What is a method? In OO programming, we do not want to directly manipulate the data of an object from the outside; on the contrary, the object itself knows how to manipulate itself (when properly requested ).You may say that we pass a message to an
The real world is full of objects. We can classify them. for example, when a very small child sees a dog, no matter what type it is, they will be called "bow-wow". We are born to have the ability to understand the world by type.In terms of OO
In daily life, we classify all objects at a certain level. we know that all cats are mammals, and all mammals are animals. small classes from largerClass. If all the mammals want to breathe, then the CAT also needs to breathe.In Ruby, we can express
Global variables start with $. They can be accessed anywhere in the program. Before initialization, the global variables have a special value nil.Ruby> $ fooNilRuby> $ foo = 55Ruby> $ foo5Use global variables with caution. they are quite dangerous
A constant starts with an uppercase letter. it should be assigned a maximum of once. in the current Ruby version, a constant value assignment only generates warnings rather than errors (non-ANSI eval. rb will not report this warning)Ruby> fluid = 303
An unexpected problem occurs in a running program. A file to be read does not exist. When you want to store some data, the disk is full. You may enter inappropriate data.Ruby> file = open ("some_file ")ERR: (eval): 1: in 'open': No such file or
The Fruit class in the previous section has two real variables, indicating the Fruit type and status respectively. it was not until we wrote a customized inspect method for this class that we knew it would not give a reasonable explanation of a
# Scanweb. rb# Use ruby scanweb. rb www.jb51.net to save the current result in c: \ 1.txtRequire 'net/http'Filename = File. new ('C: \ 1.txt ', "w + ")If $ * [0] = nilPuts "hehe, no URL entered"ElseH = Net: HTTP. new ($ * [0], 80)Resp, data = h. get
The Code is as follows:Copy codeThe Code is as follows:Require 'date'Day = Date. new (2008, 2,-1)End_of_month = day. strftime ('% D'). to_ IYear_and_month = day. strftime ('% Y % m ')For today in 1 .. end_of_month doP sprintf ('% s % 02d',
I. MethodsThe Ruby method definition allows you to set default values for parameters. However, parameters without default values (* and &) cannot be followed by parameters with default values &), that is to say, the following method definition is
The new version of will_paginate has abandoned this practice and switched to the gem method. This article builds an application named foobar to understand the usage of will_paginate.====================================C: \> rails foobar-d mysqlC: \>
1. Search for the BEGIN statement first, and execute the statement if you find it; otherwise, the first line of the program will be executed.2. When it comes to function definitions, class definitions, and module definitions, these things are
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.