diff options
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 |
