Sha256: fa107dc20a79204cf1bd0b3b63d1db0b01b3518690d3fe2470d5c41b8a098429
Contents?: true
Size: 628 Bytes
Versions: 5
Compression:
Stored size: 628 Bytes
Contents
module Teacup module_function def calculate(view, dimension, amount) if amount.is_a? Proc view.instance_exec(&amount) elsif amount.is_a?(String) && amount.include?('%') location = amount.index '%' offset = amount[(location+1)..-1].gsub(' ', '').to_f percent = amount[0...location].to_f / 100.0 case dimension when :width CGRectGetWidth(view.superview.bounds) * percent + offset when :height CGRectGetHeight(view.superview.bounds) * percent + offset else raise "Unknown dimension #{dimension}" end else amount end end end
Version data entries
5 entries across 5 versions & 1 rubygems