Ruby about the namespaces

2009-03-14  来源:本站原创  分类:Ruby  人气:312 

Some of the namespaces on the ruby-sharing under the understanding

The main use of namespaces are the keywords module, require, load, include

module's role is to ring up a namespace is also easy to understand, for require, load, include understanding, look at the following code under the

#A.rb
module All
def self.a
	print "a\n"
	end
end

print "loading in the A.rb\n"

#B.rb
module All
def self.b
	print "b\n"
	end
end

#test.rb

require "A"
require "B"
require "A"
require "A"
load "A.rb"
load "A.rb"

All.a

All.b 

The results are:

loading in the A.rb
loading in the A.rb

loading in the A.rb
a

b

require documents to be loaded is loaded only once, so the first loading in the A.rb are require because the role after the require Although there are a lot of trigger print out but not loading in the A.rb, after the two lines are load "A.rb" triggered whenever there is load the file will be loaded from the new one. And include a mixin

相关文章
  • Ruby about the namespaces 2009-03-14

    Some of the namespaces on the ruby-sharing under the understanding The main use of namespaces are the keywords module, require, load, include module's role is to ring up a namespace is also easy to understand, for require, load, include understanding

  • List of Ruby on XML parsing methods 2010-09-21

    Ruby on parsing XML documents RUBY XML documents on the resolution you can use this library REXML library. REXML ruby library is a XML tool kit is written using pure Ruby language, to comply with XML1.0 norms. In Ruby1.8 version and after, RUBY stand

  • In Ruby on Rails Rake Tutorial (turn) 2010-10-09

    Original: Ruby on Rails Rake Tutorial (aka. How rake turned Me into an Alcoholic) Introduction: As a rails developer, you may be familiar with the rake for your test, or use rake db: migrate to run your migrations, but you really know Rake behind the

  • Ruby on Rails Routing - Simple Examples 2009-02-27

    This article contains a list of ruby on rails routing examples. If you find you have any questions please leave a comment. Routes are processed from the top of routes.rb down. If a route is matched it will stop processing the routes.rb file and use t

  • Oracle instant clent for ruby / rails on cygwin 2009-02-27

    Environment: XP: oracle full client, ruby, rails, gem cygwin: ruby rails, gem (the version with the XP version) Needs: for cygwin is installed under the rails platform support oci Steps: <1> download oracle instant client (10.2.0.3 Instant Client Pa

  • Shoes - Construction Ruby client gadget 2009-02-28

    Shoes Ruby are cross-platform GUI applications, recently released a new version, it is a very interesting Ruby GUI client, the following are some characteristics of Introduction: 1. Cross-platform support for windows / linux / mac os 2. Very small, t

  • Alternative to Java with Ruby to do unit testing interface rest! 2009-02-28

    Ruby is long overdue to replace java more flexible and make some necessary changes in a matter of, if not deep-rooted culture of the company's java, I think. . . . . . The following are my Writing for the Rest of the interface used to make the test s

  • Pyronaridine listing! Ruby programming language 2009-03-01

    Interactive Net Purchase Excellence Amazon purchase [Original title] The Ruby Programming Language Publishing ] [ O'Reilly Media, Inc. [Author] (United States) David Flanagan; Yukihiro Matsumoto Translator [] LIAO Zhi-gang; Zhang Wo [Name] Books O'Re

  • In the Windows platform using Apache2.2 and Mongrel running Ruby on Rails 2009-03-02

    First, install Ruby, rails, mongrel and Apache2.2 Rubyforge download from the web site One-Click Ruby Install, run setup on installed ruby and rubygems. Run the command: gem install rails-y gem install mongrel-y gem install mongrel_service-y Installe

  • In the Linux platform to install and configure Ruby on Rails Detailed 2009-03-02

    ruby on rails recommend the production environment is running Linux / FreeBSD / Unix, or Unix family of operating systems, using lighttpd + FCGI solution. The following will be my Linux operating system, lighttpd + FCGI, MySQL database as an example,

  • Ruby Design Pattern 2009-03-02

    Ruby Design Pattern This book is about a focus on aspects of design patterns book. This book user-friendly way to introduce the Ruby design patterns, including an overview of Ruby, the use of Template Method Transform algorithm, using the strategy of

  • Ruby Symbol 2009-03-02

    Ruby is a completely cross-platform object-oriented scripting language, built on the Ruby-based Web framework Ruby on Rails (ROR) is the field of web development is gaining increasing acceptance. ROR substantial use of the Ruby language features, Sym

  • I heard good Ruby and Rails site 2009-03-02

    1. Ruby Inside is said to be the best news station, the subscriber number 16xxx [img] http://www.rubyinside.com/simg/logo.gif "alt =" [/ img] http://www.rubyinside.com/ 2. Rails Inside is also a news station, the subscriber number of 3xxx [img]

  • ruby MBARI large patches Performance Evaluation Report 2009-03-03

    Before JavaEye news ruby memory leak culprit - the specter of a detailed analysis of the current pointer Ruby official version (MRI version) causes memory leaks. Brent Roman today issued a Super patch , Which contains 6 patch file to resolve the Ruby

  • Topic: Shoes - Construction Ruby client gadget 2009-03-04

    http://www.javaeye.com/topic/295829 Shoes Ruby are cross-platform GUI applications, recently released a new version, it is a very interesting Ruby GUI client, the following are some characteristics of Introduction: 1. Cross-platform support for windo

  • J2EEer Learn Ruby 2009-03-04

    Ruby has long heard of the development of efficient and accurate is to use Ruby on Rails to develop WEB applications very convenient. While J2EE has a lot of very good Opensource framework, automatic code generation tools, can greatly enhance the dev

  • Ruby Rails system calls the use of Ping 2009-03-04

    Want to use call system commands under RoR, the general exec and system and the syscall Want to use in Rails, the call ping command The most common are ruby support Ping usage is as follows: Ping contains routines to test for the reachability of remo

  • Flying gems: the South American hummingbird and the Ruby programming language 2009-03-05

    <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta name="ProgId" content="Word.Document"> <meta name = "Generator" content = " Microsoft Word 12 "> <me

  • Ruby will replace Java? I think not so soon 2009-03-05

    I have heard a lot of such talk: Ruby On Rails (RoR) cool easy enough to prepare one In Web Application speed 10 times faster than Java, and it has some Java features not superior. By To, Ruby will replace Java to become the next generation of progra

  • Manual configuration in UBUNTU under ruby on rails environment 2009-03-05

    Careless mistake for the day before yesterday, the sources, the results after 810 error after the upgrade, the loss of response button. On google found a lot of trouble really, lucky point modification under the / etc/X11/xorg.conf to restore both, b