Newbie syntax questions

B

brian.kejser

Hi

In the 'test/unit' library the file unit.rb contains the following code.

module Test
module Unit
def self.run=(flag)
@run = flag
end

def self.run?
@run ||= false
end
end
end

at_exit do
unless $! || Test::Unit.run?
exit Test::Unit::AutoRunner.run($0 != "-e" && $0)
end
end

Could someone please explain the following:

1. Why is there an equals sign in the code "def self.run=(flag)" and what
does it do?

2. Why is there an equals sign in the code "@run ||= false" and what does
it do?

3. Why is the 'run' member of the 'Unit' module accessible on the line "
unless $! || Test::Unit.run?"? Doesn't this require the attr_reader syntax
in the module?

5. What does "$0 != "-e" && $0" mean and do?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top