With co-ordinates x y that are in Domieszka module I want to do ray r in
circle class. Are there some modules to serve co-ordinates or is there
the simplest way to do?
module Domieszka
attr_accessor :x, :y
def inspect
“You are in: #{@x } #{@y }”
end
def moveto(x,y)
@x = x
@y = y
return x,y
end
end
lukmus
February 2, 2012, 11:02pm
2
ray that has some length:) not co-ordinates
lukmus
February 3, 2012, 1:25am
3
Try this:
Circle = Struct.new(:x, :y)
c = Circle.new(10, 15)
puts c.inspect
lukmus
February 3, 2012, 1:37am
4
A more full-featured example:
Circle = Struct.new(:x, :y, :r)
class Circle
def move_to(x, y)
self.x = x
self.y = y
end
end
c = Circle.new(0, 0, 10)
puts c.inspect
c.move_to(5, 7)
puts c.inspect