Class: YandexSpeechApi::MP3_Player

Inherits:
Object
  • Object
show all
Defined in:
lib/yandex_speech/mp3_player.rb

Overview

Very, very simple MP3_Player that designed to work in most popular operation systems, like: Windows, Mac Os, Linux.

Defined Under Namespace

Classes: AbstractClassCreationError, Linux_MP3_Player, Mac_MP3_Player, MethodNotImplementedError, UnknownOsError, Windows_MP3_Player, WrongFileExtension

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.buildLinux_MP3_Player, ...

Player constructor.


44
45
46
47
48
49
50
# File 'lib/yandex_speech/mp3_player.rb', line 44

def build
  if to_s.split('::').last == 'MP3_Player'
    raise AbstractClassCreationError
  else
    new
  end
end

.initLinux_MP3_Player, ...

Creates MP3 player instance. Based on OS.


22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/yandex_speech/mp3_player.rb', line 22

def init
  @player ||=
    case recognize_operation_system
    when :windows
      Windows_MP3_Player.build
    when :linux
      Linux_MP3_Player.build
    when :mac_os
      Mac_MP3_Player.build
    else
      raise UnknownOsError
    end
end

Instance Method Details

#play(filename) ⇒ Object

plays the sound


94
95
96
97
98
# File 'lib/yandex_speech/mp3_player.rb', line 94

def play(filename)
  validate_mp3_format filename
  validate_requirements
  play_mp3 filename
end