diff options
| author | Tom Black <[email protected]> | 2017-05-19 22:24:02 -0400 |
|---|---|---|
| committer | Tom Black <[email protected]> | 2017-05-20 18:15:53 -0400 |
| commit | f69598768e9a3002d9e7c2acbed109016fac6ae9 (patch) | |
| tree | c716af50d3d98676704518ce9ab84f9afb7368f4 /lib | |
| parent | 8ce4acf745b27c3f1209b02cc6aeec2c40b5aa1b (diff) | |
| download | ruby2d-f69598768e9a3002d9e7c2acbed109016fac6ae9.tar.gz ruby2d-f69598768e9a3002d9e7c2acbed109016fac6ae9.zip | |
Check if audio file exists for `Sound` and `Music`
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ruby2d/music.rb | 8 | ||||
| -rw-r--r-- | lib/ruby2d/sound.rb | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/ruby2d/music.rb b/lib/ruby2d/music.rb index 410c82f..e0fdf11 100644 --- a/lib/ruby2d/music.rb +++ b/lib/ruby2d/music.rb @@ -7,7 +7,13 @@ module Ruby2D attr_reader :path def initialize(path) - # TODO: Check if file exists + + unless RUBY_ENGINE == 'opal' + unless File.exists? path + raise Error, "Cannot find audio file `#{path}`" + end + end + init(path) @path = path @loop = false diff --git a/lib/ruby2d/sound.rb b/lib/ruby2d/sound.rb index 1049eee..4e0c385 100644 --- a/lib/ruby2d/sound.rb +++ b/lib/ruby2d/sound.rb @@ -7,7 +7,13 @@ module Ruby2D attr_reader :path def initialize(path) - # TODO: Check if file exists + + unless RUBY_ENGINE == 'opal' + unless File.exists? path + raise Error, "Cannot find audio file `#{path}`" + end + end + init(path) @path = path end |
