Sha256: 5bb16c3d6ba3faf534d0d35ed06f24d0b5ac72f6822ff551e9726784ca165acd
Contents?: true
Size: 906 Bytes
Versions: 2
Compression:
Stored size: 906 Bytes
Contents
module Schofield module Generators class Responses class << self; attr_accessor :generator, :re_ask end @file = File.join(Rails.root, 'tmp', 'answers.txt') def self.get question @question = question if re_ask || (answer = past_answer).nil? answer = ask end answer || '' end def self.ask re_ask = true answer = generator.ask(@question) @answers ||= {} @answers[@question] = answer || '' end def self.past_answer self.past_answers[@question] end def self.past_answers @answers ||= File.exists?(@file) ? File.open(@file, 'rb') { |f| Marshal.load(f) } : {} end def self.save File.open(@file, 'wb') { |io| Marshal.dump(@answers, io) } end def self.say string generator.say(string) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
schofield-0.3.1 | lib/generators/schofield/responses.rb |
schofield-0.3.0 | lib/generators/schofield/responses.rb |