Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/geometry.rb

Instance Method Summary collapse

Instance Method Details

#/(geometry) ⇒ Object

allows you to get new dimensions for the current array of dimensions with a given geometry string

[50, 64] / '40>' # => [40, 51]

Raises:

  • (ArgumentError)


87
88
89
90
91
92
# File 'lib/geometry.rb', line 87

def /(geometry)
  raise ArgumentError, "Only works with a [width, height] pair" if size != 2
  raise ArgumentError, "Must pass a valid geometry string or object" unless geometry.is_a?(String) || geometry.is_a?(Geometry)
  geometry = Geometry.from_s(geometry) if geometry.is_a?(String)
  geometry.new_dimensions_for first, last
end