Sha256: ca4b6495ea8e88a7b5a58d7900e4b32e5930e04e5513ab12c5ebb5747d7a197f
Contents?: true
Size: 636 Bytes
Versions: 3
Compression:
Stored size: 636 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.slice(location+1, amount.size).gsub(' ', '').to_f percent = amount.slice(0, location).to_f / 100.0 case dimension when :width view.superview.bounds.size.width * percent + offset when :height view.superview.bounds.size.height * percent + offset else raise "Unknown dimension #{dimension}" end else amount end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
teacup-2.1.13 | lib/teacup/calculations.rb |
teacup-2.1.12 | lib/teacup/calculations.rb |
teacup-2.1.11 | lib/teacup/calculations.rb |