Sha256: 699c6d1193baa6c0079f0e68ee03e0166b53205880981fa044caac5594898ddb

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

# encoding: utf-8
#
# This file is part of the pincerna gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
# Licensed under the MIT license, which can be found at https://choosealicense.com/licenses/mit.
#

module Pincerna
  # Shows addresses or coordinates on Google Maps.
  class Map < Base
    # The icon to show for each feedback item.
    ICON = Pincerna::Base::ROOT + "/images/map.png"

    # Filters a query.
    #
    # @param query [String] An address to show on Google Maps.
    # @return [Array] A list of items to process.
    def perform_filtering(query)
      {query: query}
    end

    # Processes items to obtain feedback items.
    #
    # @param results [Array] The items to process.
    # @return [Array] The feedback items.
    def process_results(results)
      type = results[:query] =~ /((-?)\d+(\.\d+)?)\s*,\s*((-?)\d+(\.\d+)?)/ ? "coordinates" : "location"
      [{title: "View #{type} on Google Maps", arg: CGI.escape(results[:query]), subtitle: "Action this item to open Google Maps in the browser.", icon: ICON}]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pincerna-1.1.3 lib/pincerna/map.rb