Hook methods are similar to event-driven devices that can perform a specific callback function after a particular event occurs, which is the hook method (more descriptive: The hook method can hook a particular event like a hook). , the Before\after
Single-piece method
Ruby allows you to add a method to a single object, a method that only takes effect on a single object, called a single piece method
Sample code
str = "Just a regular string"
def str.title?
Self.upcase = = Self
In rails, the process of sending a request (/users) is as follows:1), Browser send request (/users)2), rails routes will route the request to the Users_controller index method3), Users_controller callback use user model to get all user4, user model
Scope
Ruby does not have the characteristics of a nested scope (that is, an internal scope that can see an external scope), its scope is completely separate, and once you enter a new scope, the original binding is replaced with a new set of
The Observer pattern (sometimes referred to as the Publish/subscribe model) is one of the software design patterns.In this pattern, a target object manages all the observer objects that are dependent on it and actively notifies it when its state
What is the appearance mode?
The appearance pattern provides a unified interface for a set of different interfaces in a subsystem. The façade defines the upper interface, making subsystems easier to use by reducing complexity and hiding
Agent mode
Demand:
Xiaoming let Xiao Li Chase for him (send doll, send flowers, send chocolate)
Code with no agents:
#-*-Encoding:utf-8-*-
#追求者类
class Pursuit
attr_accessor:mm
def Initialize (mm)
@mm = mm
End
def give_dolls
1. Install Cocoapods,ruby version of the low-"start updating ruby-" began to update the gem, this is a no return AH comrades, all kinds of permission denied, various paths do not exist, various paths do not have read and write permissions, various
Since you are ready to use bootstrap in your project, you will be prompted for a ruby version at 1.9.2 during the installation of Bootstrap, while the Ruby version that is currently in use is the 1.8.7 that comes with the Mac system. So you need to
Download Rubyinstaller.
Link: http://rubyinstaller.org/downloads/. Run the installation directly
Note You need to add the following in the environment variable: \ruby\bin
Test command: Ruby-v
Install RubyGems.
Expressions and variables:There is no difference between these two points and the other mainstream programming languages, which are skipped directly here. It is important to note that x=x+1 in Ruby can be written x+=1 but does not support x + +,
The definition is simple: the instance variable @ begins, class variable @@ at the beginning to read some articles and books, the current understanding of (in fact, still do not understand, first remember, the wrong to change):
Class
The difference between Ruby learning notes-puts,p,printCommon denominator: Both are used for screen output.Different points:Puts the output will be wrapped (if the content parameter is empty, only one newline symbol is output), and if there is an
(1.. - do |x| if 5) end The use of the above flip-flop, you can be understood to be greater than or equal to 5 and less than or equal to 10 of the number printed out, that is understood as puts X if x >=5 && x but note you can not be written as
An object modelKernel ModuleKernel.private_instance_methods.grep (/^pr/)Private method1 If a method recipient is not your own, be sure to specify a recipient2 Private methods can only specify one implied recipient (private method of the tunable
First, global variablesGlobal variables are supported in Ruby, and global variables in Ruby are characterized by the following:1) identifiers are marked with a $ start2) Global variables can be referenced from anywhere in the program3) nil. Let's
Workaround:1.koala Visual Compilation tool,Locate the engine.rb file under the sass-3.3.7 module in the installation directory, such as the following path:C:\Program Files (x86) \koala\rubygems\gems\sass-3.3.7\lib\sassENGINE.RB in this file, add a
Ruby web performance response time and rubyweb Response Time
You can calculate the loading time of a single web page.
Require 'watir-webdriver 'require 'watir-webdriver-performance 'B = watir: Browser. new: chromeb. goto "http: // 172.17.3.54: 230/
Ruby: Build a Ruby environment in Linux
Ruby Learning Experience: Build a Ruby environment in Linux1. Preface2. Install the Ruby environment in Linux
I. Preface
This blog post records the establishment of the Ruby programming environment in
Monkey Patch Programming Method and Its Application in Ruby, patchruby
What is Monkey Patch )? In dynamic languages, functions are appended and changed without modifying the source code.
Objective of using Monkey patch:1. append Function2. Function
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