Sha256: 99b567cc41e347f556f288d74140cab5404abba7c501f108b4072236997c4e29
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
module Jekyll module Maps class LocationFinder def initialize(options) @documents = [] @options = options end def find(site) site.collections.each { |_, collection| filter(collection.docs) } site.data.each { |_, docs| filter(docs) } @documents.map do |document| { :latitude => document["location"]["latitude"], :longitude => document["location"]["longitude"], :title => document["title"], :url => document["url"] || document.url } end end private def filter(docs) docs.each do |doc| @documents << doc if location?(doc) && match_filters?(doc) end end private def location?(doc) !doc["location"].nil? && !doc["location"].empty? end private def match_filters?(doc) @options[:filters].each do |key, value| return false if doc[key].nil? || doc[key] != value end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
jekyll-maps-1.1.2 | lib/jekyll-maps/location_finder.rb |
jekyll-maps-1.1.1 | lib/jekyll-maps/location_finder.rb |
jekyll-maps-1.1.0 | lib/jekyll-maps/location_finder.rb |