Class: Geometer::Rectangle

Inherits:
Struct
  • Object
show all
Defined in:
lib/geometer/rectangle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dimensionsObject

Returns the value of attribute dimensions

Returns:

  • (Object)

    the current value of dimensions



2
3
4
# File 'lib/geometer/rectangle.rb', line 2

def dimensions
  @dimensions
end

#originObject

Returns the value of attribute origin

Returns:

  • (Object)

    the current value of origin



2
3
4
# File 'lib/geometer/rectangle.rb', line 2

def origin
  @origin
end

Instance Method Details

#areaObject



7
8
9
# File 'lib/geometer/rectangle.rb', line 7

def area
  dimensions.area
end

#contains?(position) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/geometer/rectangle.rb', line 3

def contains?(position)
  dimensions.contains?(position.translate(-origin)) 
end