Class: MagicCloud::Shape

Inherits:
Object
  • Object
show all
Defined in:
lib/magic_cloud/shape.rb

Overview

Basic “abstract shape” class, with all primitive functionality necessary for use it in Spriter and Layouter.

Word for wordcloud is inherited from it, and its potentially possible to inherit other types of shapes and layout them also.

Direct Known Subclasses

Word

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeShape

Returns a new instance of Shape.



9
10
11
12
13
14
15
16
# File 'lib/magic_cloud/shape.rb', line 9

def initialize
  @x = 0
  @y = 0
  @sprite = nil
  @rect = nil
  @width = 0
  @height = 0
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



18
19
20
# File 'lib/magic_cloud/shape.rb', line 18

def height
  @height
end

#rectObject (readonly)

Returns the value of attribute rect.



18
19
20
# File 'lib/magic_cloud/shape.rb', line 18

def rect
  @rect
end

#spriteObject

Returns the value of attribute sprite.



18
19
20
# File 'lib/magic_cloud/shape.rb', line 18

def sprite
  @sprite
end

#widthObject (readonly)

Returns the value of attribute width.



18
19
20
# File 'lib/magic_cloud/shape.rb', line 18

def width
  @width
end

#xObject

Returns the value of attribute x.



18
19
20
# File 'lib/magic_cloud/shape.rb', line 18

def x
  @x
end

#yObject

Returns the value of attribute y.



18
19
20
# File 'lib/magic_cloud/shape.rb', line 18

def y
  @y
end

Instance Method Details

#bottomObject



49
50
51
# File 'lib/magic_cloud/shape.rb', line 49

def bottom
  y + height
end

#draw(_canvas) ⇒ Object



53
54
55
# File 'lib/magic_cloud/shape.rb', line 53

def draw(_canvas)
  fail NotImplementedError
end

#leftObject



37
38
39
# File 'lib/magic_cloud/shape.rb', line 37

def left
  x
end

#rightObject



41
42
43
# File 'lib/magic_cloud/shape.rb', line 41

def right
  x + width
end

#topObject



45
46
47
# File 'lib/magic_cloud/shape.rb', line 45

def top
  y
end