Sha256: 700590b9d13f3aa0bad0b4f477f36a40cbbb2f610044d62dff941d8f6c3276f6

Contents?: true

Size: 457 Bytes

Versions: 9

Compression:

Stored size: 457 Bytes

Contents

module Teacup
  module_function
  def calculate(view, dimension, percent)
    if percent.is_a? Proc
      view.instance_exec(&percent)
    elsif percent.is_a? String and percent[-1] == '%'
      percent = percent[0...-1].to_f / 100.0

      case dimension
      when :width
        CGRectGetWidth(view.superview.bounds) * percent
      when :height
        CGRectGetHeight(view.superview.bounds) * percent
      end
    else
      percent
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
teacup-1.2.9 lib/teacup/calculations.rb
teacup-1.2.8 lib/teacup/calculations.rb
teacup-1.2.7 lib/teacup/calculations.rb
teacup-1.2.5 lib/teacup/calculations.rb
teacup-1.2.4 lib/teacup/calculations.rb
teacup-1.2.3 lib/teacup/calculations.rb
teacup-1.2.2 lib/teacup/calculations.rb
teacup-1.0.4 lib/teacup/calculations.rb
teacup-1.0.3 lib/teacup/calculations.rb