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:
-
Why is there an equals sign in the code “def self.run=(flag)” and
what
does it do? -
Why is there an equals sign in the code “@run ||= false” and what
does
it do? -
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? -
What does “$0 != “-e” && $0” mean and do?
Thanks