Class: CGSize
- Inherits:
-
Object
- Object
- CGSize
- Defined in:
- lib/motion-ui-geometry/cgsize.rb
Instance Method Summary collapse
- #*(other) ⇒ Object
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #-@ ⇒ Object
- #/(other) ⇒ Object
- #==(other) ⇒ Object
- #=~(other) ⇒ Object
- #apply(transform) ⇒ Object
- #floor ⇒ Object
- #round ⇒ Object
- #to_dictionary ⇒ Object
- #to_point ⇒ Object
- #to_rect ⇒ Object
- #to_s ⇒ Object
- #to_value ⇒ Object
Instance Method Details
#*(other) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/motion-ui-geometry/cgsize.rb', line 44 def *(other) case other when Fixnum, Float CGSizeMake other * width, other * height when CGSize CGSizeMake width * other.width, height * other.height when CGPoint CGSizeMake width * other.x, height * other.y when CGAffineTransform CGSizeApplyAffineTransform self, other else raise TypeError, "Right operand for * must be a Fixnum, Float, "\ "CGSize, CGPoint, or CGAffineTransform (got #{other.class})" end end |
#+(other) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/motion-ui-geometry/cgsize.rb', line 18 def +(other) case other when CGSize CGSizeMake width + other.width, height + other.height when CGPoint CGSizeMake width + other.x, height + other.y else raise TypeError, "Right operand for + must be CGSize or CGPoint (got #{other.class})" end end |
#-(other) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/motion-ui-geometry/cgsize.rb', line 29 def -(other) case other when CGSize CGSizeMake width - other.width, height - other.height when CGPoint CGSizeMake width - other.x, height - other.y else raise TypeError, "Right operand for - must be CGSize or CGPoint (got #{other.class})" end end |
#-@ ⇒ Object
40 41 42 |
# File 'lib/motion-ui-geometry/cgsize.rb', line 40 def -@ CGSizeMake -width, -height end |
#/(other) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/motion-ui-geometry/cgsize.rb', line 60 def /(other) case other when Float CGSizeMake other / width, other / height when CGSize CGSizeMake width / other.width, height / other.height when CGPoint CGSizeMake width / other.x, height / other.y when CGAffineTransform CGSizeApplyAffineTransform self, other.inverse else raise TypeError, "Right operand for / must be a Float, "\ "CGSize, CGPoint, or CGAffineTransform (got #{other.class})" end end |
#==(other) ⇒ Object
3 4 5 |
# File 'lib/motion-ui-geometry/cgsize.rb', line 3 def ==(other) other.is_a?(CGSize) && width == other.width && height == other.height end |
#=~(other) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/motion-ui-geometry/cgsize.rb', line 7 def =~(other) case other when CGPoint width =~ other.x && height =~ other.y when CGSize width =~ other.width && height =~ other.height else raise TypeError, "Right operand for =~ must be CGPoint or CGSize. (got #{other.class})" end end |
#apply(transform) ⇒ Object
86 87 88 |
# File 'lib/motion-ui-geometry/cgsize.rb', line 86 def apply(transform) CGSizeApplyAffineTransform(self, transform) end |
#floor ⇒ Object
81 82 83 |
# File 'lib/motion-ui-geometry/cgsize.rb', line 81 def floor CGSizeMake width.floor, height.floor end |
#round ⇒ Object
77 78 79 |
# File 'lib/motion-ui-geometry/cgsize.rb', line 77 def round CGSizeMake width.round, height.round end |
#to_dictionary ⇒ Object
99 100 101 |
# File 'lib/motion-ui-geometry/cgsize.rb', line 99 def to_dictionary CGSizeCreateDictionaryRepresentation self end |
#to_point ⇒ Object
91 92 93 |
# File 'lib/motion-ui-geometry/cgsize.rb', line 91 def to_point CGPointMake width, height end |
#to_rect ⇒ Object
95 96 97 |
# File 'lib/motion-ui-geometry/cgsize.rb', line 95 def to_rect CGRect.new CGPointZero, self end |
#to_s ⇒ Object
107 108 109 |
# File 'lib/motion-ui-geometry/cgsize.rb', line 107 def to_s NSStringFromCGSize self end |
#to_value ⇒ Object
103 104 105 |
# File 'lib/motion-ui-geometry/cgsize.rb', line 103 def to_value NSValue.valueWithCGSize self end |