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
A real variable starts at the @, its scope is limited to the self object. Two different objects, even if they belong to the same class, can have real variables of different values. From outside the object, the real variable cannot be changed or even
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
Accept user Input
First_Name = Gets.chomp
Capitalize first letter
first_name.capitalize!
Uppercase letters
first_name.upcase!
The letter becomes lowercase
first_name.downcase!
Multi-line output
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
Use a consistent structure in the class definition.
Class Person
# Extend and include the Go
extend Somemodule
include Anothermodule
# constants are 5/>some_constant =
# Afterwards we have attribute macros
Write it out of the interpretation document code and let this part rest. It's not about playing.Use English to write notes.Use a space to separate annotations from symbols.Note more than one word should be capitalized and punctuation should be used.
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
Try upgrading Ruby with RVMhttp://blog.csdn.net/lissdy/article/details/9191351If you encounter the following problemSearching for binary rubies, this might take some time.No binary rubies available for:osx/10.11/x86_64/ruby-2.2.4.Continuing with
The class variables in Ruby, a lot of articles are not recommended, the main reason is that some of his features are prone to make some mistakes, especially in the wide use of meta-programming.The initial contact class variable may feel that he and
The basic format of the If judgment is as follows:If condition then #then可省略 processing end1. Determine if the file exists#!/usr/bin/env rubyif file.exist? ("/etc/hosts") print "OK" endPlus Else#!/usr/bin/env rubyif file.exist? ("/etc/hosts") print "
Part II Third-party frameworks and Libraries the first part of this book takes a deep dive into II main LIBRARIES:DR B and Rinda
Chapter3:ringydingy
including 6 parts:
Installation
Getting Started with
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
Said is the use of pdfkit, in fact, the work is still wkhtmltopdf.First, the new projectRails New Mypdf--skip-bundleEnter project: CD mypdf, open Gemfile:vim gemfileModify Source to Https://ruby.taobao.comAdded: Gem ' Pdfkit 'Run Bundle
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:/
Symbol: Denotes "First name", such as the name of the string, the name of the identifier.How to create a Symbol object: precede a name or string with a colon: Test: " Hello Ruby "In Ruby, each object has a unique object identifier (Identifier),
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