In the PP file for writing puppet, many of the regular expressions for Ruby are used and are commonly used as follows:
Regular expression:
[Codesyntax lang= "Ruby"]
{}: The number of repetitions (such as {4} indicates that the preceding
When you call a method, Ruby does two things.
1. Find this method. This method is called a method lookup.
2. Implement this method. To do this, Ruby needs something called self.
Such a process-discovering a method to execute-occurs in every
Global variables begin with $. They can be accessed anywhere in the program. The global variable has a special value nil before initialization.
Ruby> $foo
Nil
ruby> $foo = 5
5
Ruby> $foo
5
Global variables should be used with caution. They are
Ruby has three classes of variables, one constant, and two strict pseudo variables (pseudo-variables). There are no types for variables and constants. Although there are some drawbacks to the untyped variable, there are more advantages and good
We always want to classify unknown events. When it happens, passing a piece of code as a parameter to other methods is the easiest way to do it, which means we want to work with the code like we do with the data.
A new process object can be created
Ruby's modules are very similar to classes except:
Modules may not have entities
Modules may not have subclasses
Modules are defined by Module...end.
As a matter of fact... The module's ' Module class ' Is the class ' class ' parent class. Do
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
The following procedure has kept me in the middle of a long time, the concept of private in Ruby is really strange ...
Class Test Private
def test_print
puts ' test '
end
class Test2 here Plus self cannot invoke, private method '
Do not call the model layer directly from the view.Do not construct complex formats in the view, and output them to a method or model of the view helper.Use partial templates and layouts to reduce duplicate code.
Join the client side validation to
Keep the schema.rb under version control.Use Rake db:scheme:load instead of rake db:migrate to initialize the empty database.Use rake db:test:prepare to update the schema of the test database.
Avoid setting default data in the table. Use the model
There are several ways to create string objects, most commonly using string literals (literals), a sequence of characters between a set of single or double quotes. The difference between the two forms is that when you construct a literal, Ruby
1.Rubymine new Ror ProjectFile->new Project??Select "New Application" under R ails??Click OK after build Ror project????2. Add ControllerAfter you create a new project , right-click new on the project name??Fill in COntroller's name, click OK??Build
After my first two posts "Ruby on Rails Environment Build" and "Ruby on Rails environment build MySQL database connection" We already have all the elements to develop Ruby on rails, but it's not always easy to hit commands on a DOS window every
Note: Now the http://rubyforge.org website has stopped running, replaced by the https://rubygems.org this website, the following in the need of the gem package can go to this site search download. The rest is done exactly as you say below. Ruby on
Ruby's garbage collectorIn Ruby, almost everything you do requires memory.The job of the Ruby garbage collector is to manage memory and eventually release objects that are no longer in use. But this would sacrifice a bit of performance, and it would
#将ARGV [0] convert to regular expression typePattern= regexp.new (argv[0])#Devise Gem PackDevise is one of the most widely used authentication gem packages in Ruby. Devise provides us with complete features from registration to login, from forgotten
RVM is a Ruby version management tool that also makes it possible to load and unload ruby1. Install Curl# sudo yum Install curl# curl-l Get.rvm.io | Bash-s Stable2. It is possible to fail as3. Follow the prompts to enter the command# Curl-ssl HTTPS:/
#!/usr/bin/ruby=beginThere are 5 types of variables supported by RubyGlobal variables: The value of the uninitialized global variable begins with $0 and generates a warning using the-w option the assignment of global variables changes global state
Ruby saves the data queried by mysql to excel and rubymysql
Require "win32ole" require 'pathname' require 'mysql2' excel = WIN32OLE. new ('excel. application ') excel. visible = true # in case you want to see what happensclient = Mysql2: Client. new
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