Sophie

Sophie

distrib > Mandriva > 2010.2 > x86_64 > by-pkgid > 4eb48b954cf932f6d30c439317814ddd > files > 148

ruby1.9-doc-1.9.1.p378-3mdv2010.1.x86_64.rpm

# method access permission
# output:
#	foobar
#	Foo

class Foo
  public :printf
  def baz
    print "baz\n"
  end
  private :baz

  def quux
    print "in QUUX "
    baz()
  end
end

def foobar
  print "foobar\n"
end

f = Foo.new
#Foo.private :printf
class Foo			# redefines foobar's scope
  public :foobar
end
f.foobar
f.printf "%s\n", Foo

f.quux

class Bar<Foo
  def quux
    super
    baz()
  end
end

Bar.new.quux