Module: PhotoCook::Dimensions

Included in:
PhotoCook
Defined in:
lib/photo-cook/dimensions.rb

Instance Method Summary collapse

Instance Method Details

#check_dimensions!(width, height) ⇒ Object



11
12
13
14
15
# File 'lib/photo-cook/dimensions.rb', line 11

def check_dimensions!(width, height)
  raise WidthOutOfBoundsError     if width  < 0 || width  > 9999
  raise HeightOutOfBoundsError    if height < 0 || height > 9999
  raise NoConcreteDimensionsError if width + height == 0
end

#parse_and_check_dimensions(unsafe_width, unsafe_height) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/photo-cook/dimensions.rb', line 3

def parse_and_check_dimensions(unsafe_width, unsafe_height)
  width  = unsafe_width  == :auto ? 0 : unsafe_width.to_i
  height = unsafe_height == :auto ? 0 : unsafe_height.to_i

  check_dimensions!(width, height)
  [width, height]
end