Class: NyanCatMusicFormatter
Instance Method Summary
collapse
Instance Method Details
#kernel ⇒ Object
17
18
19
|
# File 'lib/nyan_cat_music_formatter.rb', line 17
def kernel
@kernel ||= Kernel
end
|
#kernel=(kernel) ⇒ Object
13
14
15
|
# File 'lib/nyan_cat_music_formatter.rb', line 13
def kernel=(kernel)
@kernel = kernel
end
|
#kill_music ⇒ Object
39
40
41
42
43
44
|
# File 'lib/nyan_cat_music_formatter.rb', line 39
def kill_music
if File.exists? nyan_mp3
system("killall -9 afplay &>/dev/null") if osx?
system("killall -9 mpg321 &>/dev/null") if linux?
end
end
|
#linux? ⇒ Boolean
9
10
11
|
# File 'lib/nyan_cat_music_formatter.rb', line 9
def linux?
platform.downcase.include?('linux')
end
|
#nyan_mp3 ⇒ Object
29
30
31
|
# File 'lib/nyan_cat_music_formatter.rb', line 29
def nyan_mp3
File.expand_path('../../data/nyan-cat.mp3', __FILE__)
end
|
#osx? ⇒ Boolean
5
6
7
|
# File 'lib/nyan_cat_music_formatter.rb', line 5
def osx?
platform.downcase.include?("darwin")
end
|
25
26
27
|
# File 'lib/nyan_cat_music_formatter.rb', line 25
def platform
@platform ||= RUBY_PLATFORM
end
|
21
22
23
|
# File 'lib/nyan_cat_music_formatter.rb', line 21
def platform=(platform)
@platform = platform
end
|
#start(input) ⇒ Object
33
34
35
36
37
|
# File 'lib/nyan_cat_music_formatter.rb', line 33
def start input
super
kernel.system("afplay #{nyan_mp3} &") if osx?
kernel.system("[ -e #{nyan_mp3} ] && type mpg321 &>/dev/null && mpg321 #{nyan_mp3} &>/dev/null &") if linux?
end
|