From 44fff6e26bf8ab185b632bdaedcd4b7789a7c791 Mon Sep 17 00:00:00 2001 From: Tom Black Date: Thu, 21 Apr 2016 23:45:12 -0400 Subject: Fix failing DSL test `set` must be able set a single window attribute without making others nil --- lib/ruby2d/window.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/ruby2d/window.rb b/lib/ruby2d/window.rb index 1b3698e..299a1dd 100644 --- a/lib/ruby2d/window.rb +++ b/lib/ruby2d/window.rb @@ -38,16 +38,10 @@ module Ruby2D end def set(opts) - 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 + # Store new window attributes, or ignore if nil + @title = opts[:title] || @title + @width = opts[:width] || @width + @height = opts[:height] || @height end def add(o) -- cgit v1.2.3