Sha256: 3662dbda1366e8fb32217d399a394ae1c7a7c810db3413a0dbd4a051d882f98d

Contents?: true

Size: 537 Bytes

Versions: 12

Compression:

Stored size: 537 Bytes

Contents

#encoding: UTF-8
require 'fileutils'

module Termit
  class SoundResponseHandler
    def initialize data
      @data = data
    end

    def call
      location = "#{File.expand_path('~')}/.termit"
      create_target_dir location
      File.open("#{location}/sound_response.mpeg", "wb") do |file|
        file.write(@data)
      end
      system "mpg123 -q #{location}/sound_response.mpeg"
    end

    private

    def create_target_dir location
      ::FileUtils.mkdir_p location unless File.directory?(location)
    end
  end
end



Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
termit-2.10.1 lib/termit/sound_response_handler.rb
termit-2.10.0 lib/termit/sound_response_handler.rb
termit-2.0.9 lib/termit/sound_response_handler.rb
termit-2.0.8 lib/termit/sound_response_handler.rb
termit-2.0.7 lib/termit/sound_response_handler.rb
termit-2.0.6 lib/termit/sound_response_handler.rb
termit-2.0.5 lib/termit/sound_response_handler.rb
termit-2.0.4 lib/termit/sound_response_handler.rb
termit-2.0.3 lib/termit/sound_response_handler.rb
termit-2.0.2 lib/termit/sound_response_handler.rb
termit-2.0.1 lib/termit/sound_response_handler.rb
termit-2.0.0 lib/termit/sound_response_handler.rb