Module: Balloon::Processing::ClassMethods

Defined in:
lib/balloon/processing.rb

Overview

parseing the size string

Returns:

  • (Hash)

    the options for string

Instance Method Summary collapse

Instance Method Details

#parsing_size_string(size) ⇒ Object



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/balloon/processing.rb', line 142

def parsing_size_string(size)
  symbol = ""
  symbol_regex = /[^\d|\!|\>|\<|\%|x|X]/
    if size.include?('x')
      if has_symbol = size.match(/[\!|\>|\<]/)
        symbol = has_symbol[0]
        size_option = size[0, 7].split("x")
      else
        size_option = size.split("x")
      end
      width, height = size_option
    else
      width, height = size, size
    end
  width = width || ""
  width = width.match(symbol_regex) ? "" : width
  height = height || ""
  height = height.match(symbol_regex) ?  "" : height
  return { width: width, height: height, symbol: symbol }
end