Module: Jekyll::GeoPatterns

Defined in:
lib/jekyll-geo-pattern.rb

Defined Under Namespace

Classes: Base64GeoPattern, SVGGeoPattern

Constant Summary collapse

HASH_REGEXP =
/\{.+?\}/
VALID_KEYS =
%w(base_color generator text)

Class Method Summary collapse

Class Method Details

.extract_options(input) ⇒ Object

from a string of options, construct a hash, without using ‘eval`



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/jekyll-geo-pattern.rb', line 9

def self.extract_options( input )
  opts = Hash.new
  input[1..-2].split(/, /).each do |entry|
    entryMap = entry.split(/\=>/)
    key = entryMap[0].strip[1..-1]
    next unless VALID_KEYS.include? key
    value = entryMap[1]
    opts[key.to_sym] = value.nil? ? nil : value.strip[1..-2]
  end
  opts
end