3 ms·
For me this in idiomatic ruby would be: original_style = element.style.only('top', 'left', 'width', 'height') Or if you do not want to rely on ActiveSupport
by byroot 14y ago
For me this in idiomatic ruby would be:
original_style = element.style.only('top', 'left', 'width', 'height')
Or if you do not want to rely on ActiveSupport:
original_style = Hash[%w(top left width height).map{ |p| [p, element.style[p]] }]
- alinajaf 14y agoWithout ActiveSupport I'd probably type something like this: %w(top left width height).reduce({}) { |memo, pos| memo[position] = @element.style[position] and memo }