Sha256: d0c0602e24306797b47146ccb46e5b826806f8197c48940998d9ed2b07e53c16

Contents?: true

Size: 534 Bytes

Versions: 7

Compression:

Stored size: 534 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

7 entries across 7 versions & 1 rubygems

Version Path
termit-2.13.0 lib/termit/sound_response_handler.rb
termit-2.12.1 lib/termit/sound_response_handler.rb
termit-2.12.0 lib/termit/sound_response_handler.rb
termit-2.11.2 lib/termit/sound_response_handler.rb
termit-2.11.1 lib/termit/sound_response_handler.rb
termit-2.11.0 lib/termit/sound_response_handler.rb
termit-2.10.2 lib/termit/sound_response_handler.rb