summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/ruby2d/exceptions.rb9
-rw-r--r--lib/ruby2d/image.rb11
2 files changed, 5 insertions, 15 deletions
diff --git a/lib/ruby2d/exceptions.rb b/lib/ruby2d/exceptions.rb
index 84880e1..687ab11 100644
--- a/lib/ruby2d/exceptions.rb
+++ b/lib/ruby2d/exceptions.rb
@@ -2,14 +2,5 @@
module Ruby2D
class Error < StandardError
- def colorize(msg, c); "\e[#{c}m#{msg}\e[0m" end
- def error(msg); colorize(msg, '4;31') end
- def bold(msg); colorize(msg, '1') end
-
- def initialize(msg)
- super(msg)
- puts error("\nRuby 2D Error:") << " #{msg}" <<
- bold("\nOccurred in:\n #{caller.last}\n")
- end
end
end
diff --git a/lib/ruby2d/image.rb b/lib/ruby2d/image.rb
index 7938bea..587a3c0 100644
--- a/lib/ruby2d/image.rb
+++ b/lib/ruby2d/image.rb
@@ -9,12 +9,11 @@ module Ruby2D
def initialize(x, y, path)
- # TODO: Check if file exists
- # `File.exists?` is not available in MRuby
- # Ideally would do:
- # unless File.exists? path
- # raise Error, "Cannot find image file `#{path}`"
- # end
+ unless RUBY_ENGINE == 'opal'
+ unless File.exists? path
+ raise Error, "Cannot find image file `#{path}`"
+ end
+ end
@type_id = 3
@x, @y, @path = x, y, path