Skip to content

Instantly share code, notes, and snippets.

@ashleytbasinger
Created August 27, 2013 13:04
Show Gist options
  • Save ashleytbasinger/f7aaa04f7c82569caa76 to your computer and use it in GitHub Desktop.
Save ashleytbasinger/f7aaa04f7c82569caa76 to your computer and use it in GitHub Desktop.
ruby circle
class Circle
# attr_accessor :radius
def initialize(radius)
@radius = radius.to_i
end
def diameter
@diameter = @radius * 2
end
def circumference
@circumference = @diameter * Math::PI
end
def area
@area = Math::PI * @radius * @radius
end
end
round_thing = Circle.new(3)
puts round_thing
puts round_thing.diameter
puts round_thing.circumference
puts round_thing.area
#diameter = radius *2
#circumference = diameter * pi
#area = pi * radius * radius
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment