Class: Gtk::Pong::CenteredItem

Inherits:
Object
  • Object
show all
Defined in:
lib/games_paradise/pong/gtk/cairo_pong.rb

Direct Known Subclasses

CenteredCircle, CenteredRect

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, width, height) ⇒ CenteredItem

#

initialize

#


24
25
26
27
28
29
# File 'lib/games_paradise/pong/gtk/cairo_pong.rb', line 24

def initialize(x, y, width, height)
  @x = x
  @y = y
  @width = width
  @height = height
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



19
20
21
# File 'lib/games_paradise/pong/gtk/cairo_pong.rb', line 19

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



19
20
21
# File 'lib/games_paradise/pong/gtk/cairo_pong.rb', line 19

def width
  @width
end

#xObject

Returns the value of attribute x.



18
19
20
# File 'lib/games_paradise/pong/gtk/cairo_pong.rb', line 18

def x
  @x
end

#yObject

Returns the value of attribute y.



18
19
20
# File 'lib/games_paradise/pong/gtk/cairo_pong.rb', line 18

def y
  @y
end

Instance Method Details

#max_xObject



35
36
37
# File 'lib/games_paradise/pong/gtk/cairo_pong.rb', line 35

def max_x
  @x + @width / 2
end

#max_yObject



43
44
45
# File 'lib/games_paradise/pong/gtk/cairo_pong.rb', line 43

def max_y
  @y + @height / 2
end

#min_xObject



31
32
33
# File 'lib/games_paradise/pong/gtk/cairo_pong.rb', line 31

def min_x
  @x - @width / 2
end

#min_yObject



39
40
41
# File 'lib/games_paradise/pong/gtk/cairo_pong.rb', line 39

def min_y
  @y - @height / 2
end