module CanBeConstrained

Public Instance Methods

common_superview(v) click to toggle source
# File lib/purplish-layout/can_be_constrained.rb, line 11
def common_superview(v)
  if v.superview == self
    self
  elsif superview == v
    v
  else
    (superviews & v.superviews)[0]
  end
end
constrained_views(*views, &block) click to toggle source
# File lib/purplish-layout/can_be_constrained.rb, line 7
def constrained_views(*views, &block)
  block.call(*(views.map {|e| e.constraint}))
end
constraint() click to toggle source
# File lib/purplish-layout/can_be_constrained.rb, line 2
def constraint
  #Don't bother storing it, and most importantly, don't reuse it because things like multipler and constant must always be reset
  PurplishLayout::ConstraintProxy.new(self)
end
superviews() click to toggle source
# File lib/purplish-layout/can_be_constrained.rb, line 21
def superviews
  v = self
  result = []
  loop do
    v = v.superview
    break unless v
    result << v
  end
  result
end