Class: Ellipse

Inherits:
Figure show all
Defined in:
lib/sitac_objects.rb

Overview

Represents a ellipse, given its center and radii

Direct Known Subclasses

Circle

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SITACObjects

#as_point

Constructor Details

#initialize(name, center, hradius, vradius) ⇒ Ellipse

Returns a new instance of Ellipse.

Parameters:

  • name (String)

    the name of the ellipse

  • center (Point, Array)

    the center of the ellipse

  • hradius (Float)

    the horizontal radius of the ellipse

  • vradius (Float)

    the vertical radius of the ellipse



130
131
132
133
134
135
136
# File 'lib/sitac_objects.rb', line 130

def initialize(name, center, hradius, vradius)
  super
  @name = name
  @center = as_point(center)
  @hradius = hradius / 2
  @vradius = vradius / 2
end

Instance Attribute Details

#centerObject (readonly)

Returns the value of attribute center.



124
125
126
# File 'lib/sitac_objects.rb', line 124

def center
  @center
end

#hradiusObject (readonly)

Returns the value of attribute hradius.



124
125
126
# File 'lib/sitac_objects.rb', line 124

def hradius
  @hradius
end

#nameObject (readonly)

Returns the value of attribute name.



124
125
126
# File 'lib/sitac_objects.rb', line 124

def name
  @name
end

#vradiusObject (readonly)

Returns the value of attribute vradius.



124
125
126
# File 'lib/sitac_objects.rb', line 124

def vradius
  @vradius
end

Instance Method Details

#accept(visitor) ⇒ Object



138
139
140
# File 'lib/sitac_objects.rb', line 138

def accept(visitor)
  visitor.visit_ellipse self
end