Class: MotionKit::Parent
Overview
Simple class that returns data about the parent element for use while setting the styles of a child element.
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
Instance Method Summary collapse
- #center ⇒ Object
- #center_x ⇒ Object
- #center_y ⇒ Object
- #height ⇒ Object
-
#initialize(element) ⇒ Parent
constructor
A new instance of Parent.
- #origin ⇒ Object
- #size ⇒ Object
- #width ⇒ Object
- #x ⇒ Object
- #y ⇒ Object
Constructor Details
#initialize(element) ⇒ Parent
Returns a new instance of Parent.
9 10 11 |
# File 'lib/motion-kit/layouts/parent.rb', line 9 def initialize(element) @element = element end |
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
7 8 9 |
# File 'lib/motion-kit/layouts/parent.rb', line 7 def element @element end |
Instance Method Details
#center ⇒ Object
45 46 47 |
# File 'lib/motion-kit/layouts/parent.rb', line 45 def center CGPointMake(center_x, center_y) if width && height end |
#center_x ⇒ Object
37 38 39 |
# File 'lib/motion-kit/layouts/parent.rb', line 37 def center_x width / 2.0 if width end |
#center_y ⇒ Object
41 42 43 |
# File 'lib/motion-kit/layouts/parent.rb', line 41 def center_y height / 2.0 if height end |
#height ⇒ Object
33 34 35 |
# File 'lib/motion-kit/layouts/parent.rb', line 33 def height try(:frame, :size, :height) end |
#origin ⇒ Object
13 14 15 |
# File 'lib/motion-kit/layouts/parent.rb', line 13 def origin try(:frame, :origin) end |
#size ⇒ Object
17 18 19 |
# File 'lib/motion-kit/layouts/parent.rb', line 17 def size try(:frame, :size) end |
#width ⇒ Object
29 30 31 |
# File 'lib/motion-kit/layouts/parent.rb', line 29 def width try(:frame, :size, :width) end |
#x ⇒ Object
21 22 23 |
# File 'lib/motion-kit/layouts/parent.rb', line 21 def x try(:frame, :origin, :x) end |
#y ⇒ Object
25 26 27 |
# File 'lib/motion-kit/layouts/parent.rb', line 25 def y try(:frame, :origin, :y) end |