Class Circle

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

ray that has some length:) not co-ordinates

Try this:

Circle = Struct.new(:x, :y)

c = Circle.new(10, 15)
puts c.inspect

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs