Sha256: 68011230731e8fc2782ebbe41e4b4d83cad4e98e0fc20446698faf07106b44c5

Contents?: true

Size: 475 Bytes

Versions: 1

Compression:

Stored size: 475 Bytes

Contents

module GoogleTranslateTts
  module Fileable
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      def with_temp_file(name = "tts-#{SecureRandom.uuid}", &block)
        setup_temp_dir!

        Tempfile.create(name, self::TTS_TMP_DIR) do |file|
          block.call(file)
        end
      end

      def setup_temp_dir!
        FileUtils.mkdir_p(self::TTS_TMP_DIR) unless Dir.exists? self::TTS_TMP_DIR
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
google-translate-tts-0.1.0 lib/google_translate_tts/fileable.rb