Class: MotionKit::ConstraintPlaceholder

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-kit-cocoa/constraints/constraint_placeholder.rb

Instance Method Summary collapse

Constructor Details

#initialize(type, name, value = nil) ⇒ ConstraintPlaceholder

Returns a new instance of ConstraintPlaceholder.



4
5
6
7
8
# File 'lib/motion-kit-cocoa/constraints/constraint_placeholder.rb', line 4

def initialize(type, name, value=nil)
  @type = type
  @name = name
  @value = value
end

Instance Method Details

#resolve(layout) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/motion-kit-cocoa/constraints/constraint_placeholder.rb', line 10

def resolve(layout)
  case @type
  when :first
    layout.get_view(@name)
  when :last
    layout.last_view(@name)
  when :nth
    layout.nth_view(@name, @value)
  end
end