Sha256: 2c085c23f39bd643986b5d7574f0ef724fc48254b10308efd321ad89170d5b4d

Contents?: true

Size: 557 Bytes

Versions: 3

Compression:

Stored size: 557 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.mp3", "wb") do |file|
        file.write(@data)
      end
      system "mpg123 -q #{location}/sound_response.mp3 > /dev/null 2> /dev/null"
    end

    private

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
termit-3.1.1 lib/termit/sound_response_handler.rb
termit-3.1.0 lib/termit/sound_response_handler.rb
termit-3.0.2 lib/termit/sound_response_handler.rb