Class: Termit::SoundResponseHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/termit/sound_response_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ SoundResponseHandler

Returns a new instance of SoundResponseHandler.



6
7
8
# File 'lib/termit/sound_response_handler.rb', line 6

def initialize data
  @data = data
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
# File 'lib/termit/sound_response_handler.rb', line 10

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