Module: Nyan::Shape

Included in:
Sprite, Stage
Defined in:
lib/nyan/shape.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bottomObject

Returns the value of attribute bottom.



3
4
5
# File 'lib/nyan/shape.rb', line 3

def bottom
  @bottom
end

#leftObject

Returns the value of attribute left.



3
4
5
# File 'lib/nyan/shape.rb', line 3

def left
  @left
end

#rightObject

Returns the value of attribute right.



3
4
5
# File 'lib/nyan/shape.rb', line 3

def right
  @right
end

#topObject

Returns the value of attribute top.



3
4
5
# File 'lib/nyan/shape.rb', line 3

def top
  @top
end

Instance Method Details

#inside?(other_shape) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/nyan/shape.rb', line 12

def inside?(other_shape)
  !outside(other_shape)
end

#outside?(other_shape) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
# File 'lib/nyan/shape.rb', line 5

def outside?(other_shape)
  (right < other_shape.left)   or
    (top > other_shape.bottom) or
    (left > other_shape.right) or
    (bottom < other_shape.top)
end