Skip to content

Instantly share code, notes, and snippets.

View hamitturkukaya's full-sized avatar

H. Türkü Kaya hamitturkukaya

View GitHub Profile
@hamitturkukaya
hamitturkukaya / resizeable.rb
Created November 30, 2014 14:44
Conditional resize
module Resizeable
def resize(hash)
key = hash.keys[0]
keys = hash[key].keys
arr = hash[key].values
val = {}
keys.each_with_index do |k, i|
val = val.merge(k => "#{arr[i][0]}x#{arr[i][1]}#")
end
return val unless self.send("#{key}?")