Module: PhotoCook::Resize::Mode

Defined in:
lib/photo-cook/resize/mode.rb

Defined Under Namespace

Classes: Unknown

Class Method Summary collapse

Class Method Details

.check!(mode) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/photo-cook/resize/mode.rb', line 22

def check!(mode)
  case mode
    when :fill, :fit then true
    else raise Unknown, mode
  end
  true
end

.parse(mode) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/photo-cook/resize/mode.rb', line 8

def parse(mode)
  case mode
    when true          then :fill
    when false         then :fit
    when :fit, :fill   then mode
    when 'fit', 'fill' then mode.to_sym
  end
end

.parse!(mode) ⇒ Object



17
18
19
20
# File 'lib/photo-cook/resize/mode.rb', line 17

def parse!(mode)
  check!(mode = parse(mode))
  mode
end