summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorTom Black <[email protected]>2016-03-13 14:54:18 -0400
committerTom Black <[email protected]>2016-03-13 14:54:18 -0400
commitc0db462af1ffba389c865efefd5f0344879387ba (patch)
treebfa8789e6e83d891823ca323fade2ea8c76f6d2e /lib
parentbd462a58f1c331138f978c8157cbf87428bc9e80 (diff)
parent721b7dc6d75dd3cd3ddd1a5c1a4a2ac2dea44f14 (diff)
downloadruby2d-c0db462af1ffba389c865efefd5f0344879387ba.tar.gz
ruby2d-c0db462af1ffba389c865efefd5f0344879387ba.zip
Merge pull request #13 from caporta/set-method-refactor
Set method refactor
Diffstat (limited to 'lib')
-rw-r--r--lib/ruby2d/window.rb19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/ruby2d/window.rb b/lib/ruby2d/window.rb
index 322d94c..1b3698e 100644
--- a/lib/ruby2d/window.rb
+++ b/lib/ruby2d/window.rb
@@ -38,16 +38,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