<commit_before># @requires MotionKit::UIViewLayout
module MotionKit
  class UIViewLayout

    def x(value)
      f = target.frame
      f.origin.x = MotionKit.calculate(target, :width, value)
      target.frame = f
      return CGRectGetMinX(f)
    end
    alias left x

    def right(value)
      f = target.frame
      f.origin.x = MotionKit.calculate(target, :width, value) - f.size.width
      target.frame = f
      return CGRectGetMaxX(f)
    end

    def center_x(value)
      c = target.center
      c.x = MotionKit.calculate(target, :width, value)
      target.center = c
      return CGRectGetMidX(target.frame)
    end
    alias middle_x center_x

    def y(value)
      f = target.frame
      f.origin.y = MotionKit.calculate(target, :height, value)
      target.frame = f
      return CGRectGetMinY(f)
    end
    alias top y

    def bottom(value)
      f = target.frame
      f.origin.y = MotionKit.calculate(target, :height, value) - f.size.height
      target.frame = f
      return CGRectGetMaxY(f)
    end

    def center_y(value)
      c = target.center
      c.y = MotionKit.calculate(target, :height, value)
      target.center = c
      return CGRectGetMidY(target.frame)
    end
    alias middle_y center_y

    def width(value)
      f = target.frame
      f.size.width = MotionKit.calculate(target, :width, value)
      target.frame = f
      return CGRectGetWidth(f)
    end
    alias w width

    def height(value)
      f = target.frame
      f.size.height = MotionKit.calculate(target, :height, value)
      target.frame = f
      return CGRectGetHeight(f)
    end
    alias h height

    def origin(value)
      f = target.frame
      f.origin = MotionKit.calculate(target, :origin, value)
      target.frame = f
      return target.frame.origin
    end

    def center(value)
      target.center = MotionKit.calculate(target, :center, value)
      return target.center
    end
    alias middle center

    def size(value)
      f = target.frame
      f.size = MotionKit.calculate(target, :size, value)
      target.frame = f
      return target.frame.size
    end

    def frame(value)
      target.frame = MotionKit.calculate(target, :frame, value)
      return target.frame
    end

    def _calculate_frame(f, from: from_view, relative_to: point)
      if from_view.is_a?(Symbol)
        from_view = self.get(from_view)
      end

      from_view_size = from_view.frame.size
      o = from_view.convertPoint([0, 0], toView: target.superview)

      calculate_view = target

      if point[:x] == :reset || point[:y] == :reset
        calculate_view = UIView.alloc.initWithFrame([[0, 0], target.frame.size])
      end

      if f.is_a?(Hash)
        f = f.merge(relative: true)
      end
      f = MotionKit.calculate(calculate_view, :frame, f, target.superview)
      f.origin.x += o.x<commit_msg>well that was easy - fixes #36<commit_after># @requires MotionKit::UIViewLayout
module MotionKit
  class UIViewLayout

    def x(value)
      f = target.frame
      f.origin.x = MotionKit.calculate(target, :width, value)
      target.frame = f
      return CGRectGetMinX(f)
    end
    alias left x

    def right(value)
      f = target.frame
      f.origin.x = MotionKit.calculate(target, :width, value) - f.size.width
      target.frame = f
      return CGRectGetMaxX(f)
    end

    def center_x(value)
      c = target.center
      c.x = MotionKit.calculate(target, :width, value)
      target.center = c
      return CGRectGetMidX(target.frame)
    end
    alias middle_x center_x

    def y(value)
      f = target.frame
      f.origin.y = MotionKit.calculate(target, :height, value)
      target.frame = f
      return CGRectGetMinY(f)
    end
    alias top y

    def bottom(value)
      f = target.frame
      f.origin.y = MotionKit.calculate(target, :height, value) - f.size.height
      target.frame = f
      return CGRectGetMaxY(f)
    end

    def center_y(value)
      c = target.center
      c.y = MotionKit.calculate(target, :height, value)
      target.center = c
      return CGRectGetMidY(target.frame)
    end
    alias middle_y center_y

    def width(value)
      f = target.frame
      f.size.width = MotionKit.calculate(target, :width, value)
      target.frame = f
      return CGRectGetWidth(f)
    end
    alias w width

    def height(value)
      f = target.frame
      f.size.height = MotionKit.calculate(target, :height, value)
      target.frame = f
      return CGRectGetHeight(f)
    end
    alias h height

    def origin(value)
      f = target.frame
      f.origin = MotionKit.calculate(target, :origin, value)
      target.frame = f
      return target.frame.origin
    end

    def center(value)
      target.center = MotionKit.calculate(target, :center, value)
      return target.center
    end
    alias middle center

    def size(value)
      f = target.frame
      f.size = MotionKit.calculate(target, :size, value)
      target.frame = f
      return target.frame.size
    end

    def frame(value)
      target.frame = MotionKit.calculate(target, :frame, value)
      return target.frame
    end

    def _calculate_frame(f, from: from_view, relative_to: point)
      if from_view.is_a?(Symbol)
        from_view = self.get(from_view)
      end

      from_view_size = from_view.frame.size
      o = from_view.convertPoint([0, 0], toView: target.superview)

      calculate_view = UIView.alloc.initWithFrame([[0, 0], target.frame.size])

      if f.is_a?(Hash)
        f = f.merge(relative: true)
      end
      f = MotionKit.calculate(calculate_view, :frame, f, target.superview)
      f.origin.x += o.x
{'fraction_non_alphanumeric': 0.09828141783029001, 'fraction_numerical': 0.0017901897601145722, 'mean_word_length': 2.347513481126423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2552696', 'n_tokens_mistral': 1893, 'n_tokens_neox': 1808, 'n_words': 438}