Skip to content

Instantly share code, notes, and snippets.

@pi-chan
Created February 2, 2014 13:38
Show Gist options
  • Save pi-chan/8768522 to your computer and use it in GitHub Desktop.
Save pi-chan/8768522 to your computer and use it in GitHub Desktop.
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