summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorTom Black <[email protected]>2017-05-19 22:24:02 -0400
committerTom Black <[email protected]>2017-05-20 18:15:53 -0400
commitf69598768e9a3002d9e7c2acbed109016fac6ae9 (patch)
treec716af50d3d98676704518ce9ab84f9afb7368f4 /lib
parent8ce4acf745b27c3f1209b02cc6aeec2c40b5aa1b (diff)
downloadruby2d-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.rb8
-rw-r--r--lib/ruby2d/sound.rb8
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