From 26c490f404731d053a6205719b6246502c07b449 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Sat, 14 Jun 2014 16:46:27 +0200 Subject: init --- ruby/class_method.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 ruby/class_method.rb (limited to 'ruby/class_method.rb') 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 + -- cgit v1.2.3