Created
February 2, 2014 13:38
-
-
Save pi-chan/8768522 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module IdeaCard | |
module ModuleMethods | |
functions = %w(goal point change) | |
current_file_path = File.dirname(__FILE__) | |
functions.each do |m| | |
eval <<-EOC | |
def #{m} | |
path = File.expand_path "./#{m}s", "#{current_file_path}" | |
@#{m}s ||= load(path) | |
@#{m}s.sample | |
end | |
EOC | |
end | |
def draw | |
"#{goal}、#{point}、#{change}" | |
end | |
private | |
def load(file) | |
f = open(file) | |
contents = f.read.split "\n" | |
f.close | |
contents | |
end | |
end | |
extend ModuleMethods | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment