开发者

Ch.5 Why's Poignant Guide to Ruby: What is endertromb?

Can some one help me understand how 'endertromb' is being u开发者_开发百科sed or where I can get it for this guide? http://poignant.guide/book/chapter-5.html

Why has 2 examples where he is trying to teach a concept about instance variables but he seems to be requesting a file endertromb.rb and using it. Am I missing something? what/how can I get this file so that I don't get errors. I've tried to Google but got nothing at all. Heres example code of how he used it:

require 'endertromb'
 class WishMaker
   def initialize
     @energy = rand( 6 )
   end
   def grant( wish )
     if wish.length > 10 or wish.include? ' '
       raise ArgumentError, "Bad wish." 
     end
     if @energy.zero?
       raise Exception, "No energy left." 
     end
     @energy -= 1
     Endertromb::make( wish )
   end
 end


Endertromb is just a class defined in another file, and thats all you need to know. As stated by _why himself in this guide:

Both the wish maker and the mind reader refer to a class named Endertromb. This class is stored in a file endertromb.rb, which is loaded with the code: require 'endertromb'.

and

The Endertromb class which contained the mysteries of this planet’s powers.


Endertromb is a class defined in the file endertromb.rb , therefore the "require 'endertromb'".

Both the wish maker and the mind reader refer to a class named Endertromb. This class is stored in a file endertromb.rb, which is loaded with the code: require 'endertromb'. Often you’ll use other classes to accomplish part of your task. Most of the latter half of this book will explore the wide variety of helpful classes that can be loaded in Ruby.

Code for this class seems to be absent in the guide (or at this part, maybe it's defined later).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜