Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 36 lines (32 sloc) 1.057 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
class ChessOpener
  def initialize
    @data = {}
    load_data
  end

  def self.load(filename)
    dsl = new
    dsl.instance_eval(File.read(filename))
  end

  def method_missing(method_name, *args, &block)
    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
  def load_data
    @data = {"a3" => ["Anderssen's Opening Polish Gambit: 1. a3 a5 2. b4",
                      "Anderssen's Opening Creepy Crawly Formation: 1. a3 e5 2. h3 d5",
                      "Anderssen's Opening Andersspike: 1. a3 g6 2. g4"],
             "h4" => ["Koola-Koola continues 1.h4 a5",
                      "Wulumulu continues 1.h4 e5 2. d4",
                      "Crab Variation continues 1.h4 any 2. a4",
                      "Borg Gambit continues 1.h4 g5.",
                      "Symmetric Variation continues 1.h4 h5"]}
  end

end
Something went wrong with that request. Please try again.