diff options
author | Patrick Simianer <p@simianer.de> | 2014-06-14 16:46:27 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-06-14 16:46:27 +0200 |
commit | 26c490f404731d053a6205719b6246502c07b449 (patch) | |
tree | 3aa721098f1251dfbf2249ecd2736434c13b1d48 /ruby/class_method.rb |
init
Diffstat (limited to 'ruby/class_method.rb')
-rwxr-xr-x | ruby/class_method.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/ruby/class_method.rb b/ruby/class_method.rb new file mode 100755 index 0000000..447a477 --- /dev/null +++ b/ruby/class_method.rb @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby + + +class A + attr_accessor :z + + def initialize + self.z = 'a' + end + + def self.a + r = self.new + return r + end +end + +class B < A + + def initialize + self.z = 'b' + end + + def b + "b" + end +end + +a = A.new +b = B.new + +puts a.z +puts b.z +puts +x = B.a +puts x.z + |