diff options
| -rw-r--r-- | lib/ruby2d/window.rb | 20 | ||||
| -rw-r--r-- | tests/testcard.rb | 1 |
2 files changed, 11 insertions, 10 deletions
diff --git a/lib/ruby2d/window.rb b/lib/ruby2d/window.rb index 322d94c..f5f81a1 100644 --- a/lib/ruby2d/window.rb +++ b/lib/ruby2d/window.rb @@ -1,4 +1,5 @@ # window.rb +require 'pry' module Ruby2D class Window @@ -38,16 +39,15 @@ module Ruby2D end def set(opts) - if opts.include? :title - @title = opts[:title] - end - - if opts.include? :width - @width = opts[:width] - end - - if opts.include? :height - @height = opts[:height] + valid_keys = [:title, :width, :height] + valid_opts = opts.reject { |k| !valid_keys.include?(k) } + if !valid_opts.empty? + @title = valid_opts[:title] + @width = valid_opts[:width] + @height = valid_opts[:height] + return true + else + return false end end diff --git a/tests/testcard.rb b/tests/testcard.rb index 1ab2267..4954d20 100644 --- a/tests/testcard.rb +++ b/tests/testcard.rb @@ -1,5 +1,6 @@ require 'ruby2d' +binding.pry set width: 700, height: 500, title: "Ruby 2D – Testcard" # Read window attributes |
