module Vpsb class BaseAskResource < BaseResource include AskSupport def self.question(text) @question = text end def question self.class.instance_variable_get(:@question) end def self.default(text) @default = text end def default self.class.instance_variable_get(:@default) end def call(data) answer = ask_loop(validate) do puts question end finalize(answer.strip) end protected def finalize(answer) return default if answer.empty? && !default.nil? answer end def validate return Proc.new { true } if !default.nil? nil end end end