Describes a class-like construct: a module. When designing a program, we divide the large components into small chunks, and you can mix and match the behavior of the objects.
Similar to classes, modules also bundle methods with constants. What is different is that there are no instances of the module. You can use a module that has a particular function in a class or in a particular object.
Class is a subclass of the module class, which means that all class objects should also be a module objec
code block.
A code block can only appear behind a method. It is followed by the same line of the last parameter of the method. Generally, the yield keyword calls the code in the code block.
Module python
The module enables you to logically organize your Python code segments.
Assigning relevant code to a module makes your code easier to use and understand.
The module is also a Python object and has random name attributes for binding or reference.
Simply put, a module is a file that saves Pytho
Share with us today the basic Ruby Tutorial (http://www.maiziedu.com/course/ruby-px/), which focuses on Ruby Source and Ruby features, here's a look at Ruby 's introduction:Ruby is a purely object-oriented programming language. It was created in 1993 year by as of Japan (まつ
About Ruby on Rails
Ruby on Rails is an application stack that provides developers with a framework to quickly create a variety of Web applications. ruby on Rails does take a little while to install on a virtual server, but luckily there are a lot of helpful tools to make this process as easy as possible. you can run this tutorial on your droplet as a user with S
In-depth analysis of the use of the command mode in Ruby Design Mode Programming, ruby Design Mode
The command mode is the design mode with a high usage of the object behavior type, alias: Action, Transaction)
Intent: encapsulate a request as an object so that you can parameterize different requests, queue requests or record request logs, and support cancelable operationsThe so-called "different requests" a
Example parsing: Implementation of observer mode in Ruby design mode development, and ruby Design Mode
In general, the observer mode should be defined as follows: building a clean interface between the source of news that some object has changed and the consumers of that news.
The observer mode establishes a clean interface between the producer and consumer of the message, so that the coupling between the p
Use Ruby to process text tutorials, and use ruby to process text tutorials
Similar to Perl and Python, Ruby has excellent functions and is a powerful text processing language. This article briefly introduces Ruby's text data processing function and how to use Ruby to effectively process text data in different formats,
puts "big box area is: # @area '
end
# make it protected
protected:p RI Ntarea
End
# Create an object
box = Box.new (M) # call
instance methods
A = Box.getarea ()
puts "Area of the box are: #{a}"
# try to call protected or methods
Box.printarea ()
When the above code is executed, the following results are generated. In this case, the first method is invoked successfully, but the second method gives a hint.
Area of the box is:200
test.rb:42:protected method '
Example of an interactive program developed by ruby: ruby Development
Implement the interaction function in a terminal similar to pry, ronin, and msf. ripl gem is mainly used here:
1. Call defined methods, such as help2. Be able to execute system commands3. ruby parsing similar to irb/pry
Installation:
gem install riplgem install ripl-shell_commands
Example
Ripl,
Deploy the Ruby server and ruby# Create a project directory/Opt/logs/TV-cibn-cms# Install rbenv and ruby 1.9.3 IN ruby# Install and compile related packagesYum install-y gcc openssl-devel libyaml-devel readline-devel zlib-develSu-ruby #/home/
Python and Ruby are both excellent languages, all of which emphasize people-oriented and have their own merits. However, I feel Ruby seems more friendly. Ruby draws on the advantages of smalltalk, Python, and Perl.
We recommend that you learn Ruby resources:
English
Clear and short free ebook, I think it is
When learning a new programming language, we must be clear about a few questions:What is the type model of the language?Strongly typed / weakly typed, static type / dynamic typeThe type model changes the way the problem is handled and controls how the language runsWhat is the programming paradigm of language?Object-oriented, functional, procedural, etc.How to interact with the language?Compiling, interpretingWhat is the judgment structure of language (decision construct) and the core data struct
Ruby's installation can go to Ruby's official web site to download the Ruby1.56 Windows Installer package, install the after installation, open the DOS window, input ruby-v display
Ruby 1.8.6 (2007-03-13 patchlevel 0) [I386-mswin32] shows that Ruby has been installed successfully and the version number is Ruby 1.96.
Explain the methods in Ruby and the Ruby Methods
The Ruby method is very similar to the functions in other programming languages. The Ruby method is used to bind one or more repeated statements in a unit.
The method name should start with a lowercase letter. If the name of a method starts with an uppercase letter,
Analysis of Ruby relay and message-related knowledge, analysis of ruby
Inheritance allows you to create a class as the refinement and specialization of another class ). For example, in our automatic karaoke system, the concept of "Song" is encapsulated in the Song category. Then, as the market grows, we need to provide karaoke support. A karaoke song is no different from other songs (it just does not have a
How to learn Ruby? What do you need to know before you learn Ruby? This is a lot of people want to learn the voice of Ruby friends, I do not give a specific answer, the following to tell you about a predecessor learning Ruby (http://www.maiziedu.com/course/ruby/) learning pr
Gems use proxies in two ways:
Mode one:
>>set http_proxy=http://ip_or_host:port
>>gem Install The_package_name
Mode two:
>>gem list-p Http://user:passwd@ip_or_host:8080-r
Install Ruby-debug-base19There are 2 different ways:Method One:download the. gem file first, then install the. gem file directly, which requires compilation, so you need to take the With-ruby-in
# instance methods for output areas
def printarea
@area = getwidth () * getheight
puts "big box area is: # @area"
end
# Let instance method be protected
protected:p Rintarea end
# Create object
box = Box.new (Ten)
# Call instance method
a = Box.getarea ()
puts "area of the box is: #{a}"
# attempts to invoke an instance method of protected
Box.printarea ()
When the above code executes, it produces the following results. In this case, the first method call succeeds,
Ruby syntax notes, ruby syntax
Accept user input
first_name = gets.chomp
Uppercase letters
first_name.capitalize!
Uppercase letters
first_name.upcase!
Lower letters
first_name.downcase!
Multi-row output
Print
Note
# I am a comment
Variable acquisition
#{first_name}
Variable
Global variable $
Class variable @@
Method variable @
Local variables are lowercase letters or _
If/else
if a
Class
class
Basic instructions for using regular expressions in Ruby, ruby Regular Expressions
Built-in support for regular expressions is usually limited to scripting languages such as Ruby, Perl, and awk. This is a shame: although regular expressions are mysterious, they are a powerful text processing tool. It is quite different to support it through built-in instead of li
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.