Class: Cylinder

Inherits:
Object show all
Defined in:
lib/roby/state/shapes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#axisObject

Returns the value of attribute axis.



2
3
4
# File 'lib/roby/state/shapes.rb', line 2

def axis
  @axis
end

#heightObject

Returns the value of attribute height.



2
3
4
# File 'lib/roby/state/shapes.rb', line 2

def height
  @height
end

#radiusObject

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

#lengthObject



14
# File 'lib/roby/state/shapes.rb', line 14

def length; diameter(:z) end

#widthObject



15
# File 'lib/roby/state/shapes.rb', line 15

def width; diameter(:z) end