Sha256: a17f9c0ac4eea269124c64ca35512cc9ec90495514b876e16b08b921ded77494

Contents?: true

Size: 663 Bytes

Versions: 5

Compression:

Stored size: 663 Bytes

Contents

class Cylinder
    attr_accessor :radius, :height, :axis
    def initialize(radius, height, axis)
        @radius, @height, @axis = radius.to_f, height.to_f, axis.to_f
    end
    def diameter(axis)
	if axis == self.axis
	    radius * 2
	else
	    raise NotImplementedError
	end
    end
    alias :max_length :diameter 
    def length; diameter(:z) end 
    def width; diameter(:z) end 
end

class Cube
    attr_accessor :length, :width, :height
    def initialize(length, width, height)
	@length, @width, @height = length.to_f, width.to_f, height.to_f
    end

    def max_length(axis)
	if axis == :z
	    [length, width].max
	else
	    height
	end
    end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
roby-0.8.0 lib/roby/state/shapes.rb
roby-0.7.2 lib/roby/state/shapes.rb
roby-0.7.1 lib/roby/state/shapes.rb
roby-0.7 lib/roby/state/shapes.rb
roby-0.7.3 lib/roby/state/shapes.rb