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.



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

#axisObject

Returns the value of attribute axis.



4
5
6
# File 'lib/roby/state/shapes.rb', line 4

def axis
  @axis
end

#heightObject

Returns the value of attribute height.



4
5
6
# File 'lib/roby/state/shapes.rb', line 4

def height
  @height
end

#radiusObject

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

#lengthObject



18
19
20
# File 'lib/roby/state/shapes.rb', line 18

def length
    diameter(:z)
end

#widthObject



22
23
24
# File 'lib/roby/state/shapes.rb', line 22

def width
    diameter(:z)
end