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.
6 7 8 |
# File 'lib/roby/state/shapes.rb', line 6 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.
4 5 6 |
# File 'lib/roby/state/shapes.rb', line 4 def axis @axis end |
#height ⇒ Object
Returns the value of attribute height.
4 5 6 |
# File 'lib/roby/state/shapes.rb', line 4 def height @height end |
#radius ⇒ Object
Returns the value of attribute radius.
4 5 6 |
# File 'lib/roby/state/shapes.rb', line 4 def radius @radius end |
Instance Method Details
#diameter(axis) ⇒ Object Also known as: max_length
10 11 12 13 14 15 16 |
# File 'lib/roby/state/shapes.rb', line 10 def diameter(axis) if axis == self.axis radius * 2 else raise NotImplementedError end end |
#length ⇒ Object
18 19 20 |
# File 'lib/roby/state/shapes.rb', line 18 def length diameter(:z) end |
#width ⇒ Object
22 23 24 |
# File 'lib/roby/state/shapes.rb', line 22 def width diameter(:z) end |