Module: Skeptick::Sugar::Geometry

Included in:
Skeptick
Defined in:
lib/skeptick/sugar/geometry.rb

Instance Method Summary collapse

Instance Method Details

#geometry(options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/skeptick/sugar/geometry.rb', line 4

def geometry(options = {})
  result = ''

  result << if options[:size]
    options[:size]
  else
    if options[:width] && options[:height]
      "#{options[:width]}x#{options[:height]}"
    elsif options[:width]
      "#{options[:width]}x"
    elsif options[:height]
      "x#{options[:height]}"
    else
      ''
    end
  end

  if options[:left] || options[:top]
    left = '%+d' % (options[:left] || 0)
    top  = '%+d' % (options[:top]  || 0)
    result << "#{left}#{top}"
  end

  result << '%' if options[:percentage]
  result << '!' if options[:exact]
  result << '<' if options[:expand_only]
  result << '>' if options[:shrink_only]

  result
end