Class: Cylinder
Instance Attribute Summary collapse
-
#axis ⇒ Object
Returns the value of attribute axis.
-
#height ⇒ Object
Returns the value of attribute height.
-
#radius ⇒ Object
Returns the value of attribute radius.
Instance Method Summary collapse
- #diameter(axis) ⇒ Object (also: #max_length)
-
#initialize(radius, height, axis) ⇒ Cylinder
constructor
A new instance of Cylinder.
- #length ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(radius, height, axis) ⇒ Cylinder
Returns a new instance of Cylinder.
3 4 5 |
# File 'lib/roby/state/shapes.rb', line 3 def initialize(radius, height, axis) @radius, @height, @axis = radius.to_f, height.to_f, axis.to_f end |
Instance Attribute Details
#axis ⇒ Object
Returns the value of attribute axis.
2 3 4 |
# File 'lib/roby/state/shapes.rb', line 2 def axis @axis end |
#height ⇒ Object
Returns the value of attribute height.
2 3 4 |
# File 'lib/roby/state/shapes.rb', line 2 def height @height end |
#radius ⇒ Object
Returns the value of attribute radius.
2 3 4 |
# File 'lib/roby/state/shapes.rb', line 2 def radius @radius end |
Instance Method Details
#diameter(axis) ⇒ Object Also known as: max_length
6 7 8 9 10 11 12 |
# File 'lib/roby/state/shapes.rb', line 6 def diameter(axis) if axis == self.axis radius * 2 else raise NotImplementedError end end |
#length ⇒ Object
14 |
# File 'lib/roby/state/shapes.rb', line 14 def length; diameter(:z) end |
#width ⇒ Object
15 |
# File 'lib/roby/state/shapes.rb', line 15 def width; diameter(:z) end |