Permalink
Browse files

Removing unneccesary methods

  • Loading branch information...
1 parent f864a25 commit 9ac4bec827cf59ecbd4f97f4334ee6e85459b661 @kalmanh kalmanh committed Dec 30, 2011
Showing with 12 additions and 17 deletions.
  1. +12 −17 chess_opener.rb
View
@@ -3,27 +3,22 @@ def initialize
@data = {}
load_data
end
-
+
def self.load(filename)
dsl = new
dsl.instance_eval(File.read(filename))
end
-
- def h4
- puts "=========="
- puts @data.assoc("h4")
- puts "=========="
- end
-
- def a3
- puts "=========="
- puts @data.assoc("a3")
- puts "=========="
- end
def method_missing(method_name, *args, &block)
- msg = "You tried to call the method #{method_name}. There is no such method."
- raise msg
+ data_array = @data.send(:[], method_name.to_s)
+ if data_array
+ puts "=========="
+ puts @data[method_name.to_s]
+ puts "=========="
+ else
+ msg = "You tried to call the method #{method_name}. There is no such method."
+ raise msg
+ end
end
private
@@ -37,5 +32,5 @@ def load_data
"Borg Gambit continues 1.h4 g5.",
"Symmetric Variation continues 1.h4 h5"]}
end
-
-end
+
+end

0 comments on commit 9ac4bec

Please sign in to comment.